Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[vB4] Unfinished Settings - fix to work
Coroner
Join Date: Feb 2008
Posts: 797

I start for about 25 years with an TI and learned Basic. Next was an Commodere 64, Amiga. On Amiga I learned Assembler and wrote some Games. Many years later again, I learned myself (without book ...) php,html and javascript. Then I wrote some small

Germany
Show Printable Version Email this Page Subscription
Coroner Coroner is offline 01-16-2010, 10:00 PM

Since vB4 is out, there are 2 new unfinished settings. At this moment those settings aren't used by vB4. I've asked in the bugtracker, but get no answer 'bout this.
I wrote my own solution to finish up those 2 settings and hope that this will be implemented in one of the next versions. I've attached a image to, see what I mean.

Ok, let's start (remember: this is a beta solution).

1st extend the database
  • ALTER TABLE `vb4_setting` CHANGE `datatype` `datatype` ENUM( 'free', 'number', 'boolean', 'bitfield', 'username', 'integer', 'posint', 'arrayinteger', 'arrayfree' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'free'
2nd create two new GLOBAL phrases
  • title = datatype_arrayinteger
    phrase = Array Integer
  • title = datatype_arrayfree
    phrase = Array Free

The next parts is to change 3 files:
open admincp/options.php
search for:
PHP Code:
        case 'username':
            
$checked= array('username' => ' checked="checked"');
            break; 
add below:
PHP Code:
        case 'arrayinteger':
            
$checked= array('arrayinteger' => ' checked="checked"');
            break;
        case 
'arrayfree':
            
$checked= array('arrayfree' => ' checked="checked"');
            break; 
search for:
PHP Code:
<label for="rb_dt_username"><input type="radio" name="datatype" id="rb_dt_username" tabindex="1" value="username"' . $checked['username'] . ' />' . $vbphrase['datatype_username'] . '</label
add below:
PHP Code:
        <label for="rb_dt_arrayinteger"><input type="radio" name="datatype" id="rb_dt_arrayinteger" tabindex="1" value="arrayinteger"' . $checked['arrayinteger'] . ' />' . $vbphrase['datatype_arrayinteger'] . '</label>
        <
label for="rb_dt_arrayfree"><input type="radio" name="datatype" id="rb_dt_arrayfree" tabindex="1" value="arrayfree"' . $checked['arrayfree'] . ' />' . $vbphrase['datatype_arrayfree'] . '</label
search for:
PHP Code:
    if (is_demo_mode())
    {
        
print_cp_message('This function is disabled within demo mode');
    }

    
$db->query_write("
        UPDATE " 
TABLE_PREFIX "setting SET
            grouptitle = '" 
$db->escape_string($vbulletin->GPC['grouptitle']) . "',
            optioncode = '" 
$db->escape_string($vbulletin->GPC['optioncode']) . "',
            defaultvalue = '" 
$db->escape_string($vbulletin->GPC['defaultvalue']) . "',
            displayorder = " 
$vbulletin->GPC['displayorder'] . ", 
and change it into:
PHP Code:
    if (is_demo_mode())
    {
        
print_cp_message('This function is disabled within demo mode');
    }

    if (
$vbulletin->GPC['datatype'] == 'arrayinteger' OR $vbulletin->GPC['datatype'] == 'arrayfree')
    {
        
$store = array ();
        if (
is_array (explode (','$vbulletin->GPC['defaultvalue'])))
        {
            foreach (
explode (','$vbulletin->GPC['defaultvalue']) as $key => $val)
            {
                
$store[] = $val;
            }
        }
        
$vbulletin->GPC['defaultvalue'] = serialize ($store);
        
$vbulletin->GPC['value'] = serialize ($store);
    }

    
$db->query_write("
        UPDATE " 
TABLE_PREFIX "setting SET
            value = '" 
$db->escape_string($vbulletin->GPC['value']) . "',
            grouptitle = '" 
$db->escape_string($vbulletin->GPC['grouptitle']) . "',
            optioncode = '" 
$db->escape_string($vbulletin->GPC['optioncode']) . "',
            defaultvalue = '" 
$db->escape_string($vbulletin->GPC['defaultvalue']) . "',
            displayorder = " 
$vbulletin->GPC['displayorder'] . ", 
search for:
PHP Code:
    print_textarea_row($vbphrase['description'], 'description'$setting['description'], 4'50" style="width:100%');
    
print_textarea_row($vbphrase['option_code'], 'optioncode'$setting['optioncode'], 4'50" style="width:100%'); 
and add below:
PHP Code:
    if ($setting['datatype'] == 'arrayinteger' OR $setting['datatype'] == 'arrayfree')
    {
        
$store unserialize ($setting['defaultvalue']);
        
$setting['defaultvalue'] = (is_array ($store) ? implode (','$store) : '');
    } 
next is to open includes/adminfunctions_options.php
search for:
PHP Code:
        // select:eval
        
case 'selectmulti:eval':
        {
            
$options null;

            eval(
$setting['optiondata']);

            if (
is_array($options) AND !empty($options))
            {
                
print_select_row($description$name '[]'$options$setting['value'], false5true);
            }
            else
            {
                
print_input_row($description$name$setting['value']);
            }
        }
        break; 
and change it into:
PHP Code:
        // select:eval
        
case 'selectmulti:eval':
        {
            
$options null;

            eval(
$setting['optiondata']);

            if (
is_array($options) AND !empty($options))
            {
                
$setting['value'] = unserialize($setting['value']);
                
$setting['value'] = (is_array($setting['value']) ? $setting['value'] : array());
                
print_select_row($description$name '[]'$options$setting['value'], false5true);
            }
            else
            {
                
print_input_row($description$name$setting['value']);
            }
        }
        break; 
search for:
PHP Code:
        case 'arrayinteger':
            
$key array_keys($value);
            
$size sizeOf($key);
            for (
$i 0$i $size$i++)
            {
                
$value[$key[$i]] = intval($value[$key[$i]]);
            }
            break;

        case 
'arrayfree':
            
$key array_keys($value);
            
$size sizeOf($key);
            for (
$i 0$i $size$i++)
            {
                
$value[$key[$i]] = trim($value[$key[$i]]);
            }
            break; 
and change those lines into:
PHP Code:
        case 'arrayinteger':
            if (!
is_array ($value))
            {
                
$value unserialize($value);
                
$value = (is_array($value) ? $value : array());
            }
            
$key array_keys($value);
            
$size sizeOf($key);
            for (
$i 0$i $size$i++)
            {
                
$value[$key[$i]] = intval($value[$key[$i]]);
            }
            
$value serialize ($value);
            break;

        case 
'arrayfree':
            if (!
is_array ($value))
            {
                
$value unserialize($value);
                
$value = (is_array($value) ? $value : array());
            }
            
$key array_keys($value);
            
$size sizeOf($key);
            for (
$i 0$i $size$i++)
            {
                
$value[$key[$i]] = trim($value[$key[$i]]);
            }
            
$value serialize ($value);
            break; 
next, open includes/adminfunctions_plugin.php
search for:
PHP Code:
                if (isset($vbulletin->options["$setting[varname]"]))
                {
                    
$newvalue $vbulletin->options["$setting[varname]"];
                }
                else
                {
                    
$newvalue $setting['defaultvalue'];
                } 
and add above:
PHP Code:
                if (trim ($setting['datatype']) == 'arrayinteger' OR trim ($setting['datatype']) == 'arrayfree')
                {
                    
$store = array ();
                    if (
is_array (explode (','trim ($setting['defaultvalue']))))
                    {
                        foreach (
explode (','trim ($setting['defaultvalue'])) AS $value)
                        {
                            
$store[] = $value;
                        }                        
                    }
                    
$setting['defaultvalue'] = serialize ($store);
                } 
Ok, with this changes you can have those settings working now.

How to use those options ?
In your product (under the settingsgroup) you can now have two more options:
This is example one:
Quote:
<setting varname="multiinput_choose" displayorder="20">
<datatype>arrayfree</datatype>
<optioncode>multiinput</optioncode>
<defaultvalue>Hello up there,where on the air,it's hockey night tonight</defaultvalue>
</setting>
The optioncode is only multiinput and the datatype MUST be arrayfree or arrayinteger.

The next example is selectmulti:eval
Quote:
<setting varname="multiselect_choose" displayorder="10">
<datatype>arrayinteger</datatype>
<optioncode>selectmulti:eval
$options = array (
'0' => 'you can choose what you want',
'1' => 'this is a multiselect field',
'2' => 'choose one or more',
'3' => 'option if you like',
'4' => 'this option wont work',
'5' => 'in a standard',
'6' => 'vBulletin 4.0.1',
); </optioncode>
<defaultvalue>1,3,4</defaultvalue>
</setting>
Here also you have to use arrayfree or arrayinteger. Others won't work !

I really hope, that those options are available in a further version of vB4.

Regards
Coroner
Attached Images
File Type: jpg Bild 1.jpg (43.5 KB, 0 views)
Reply With Quote
  #2  
Old 01-18-2010, 04:29 AM
Coroner Coroner is offline
 
Join Date: Feb 2008
Location: Germany
Posts: 797
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I forgott to tell you, how to use those settings in you mod.

For both options, you will get back an array (serialized). First unserialized the value
PHP Code:
// unserialized the value
$vbulletin->options['multiinput_choose'] = unserialized ($vbulletin-options['multiinput_choose']);
// unserialized the value 
And next is to check the array.
PHP Code:
if (in_array ('findme'$vbulletin->option['multiinput_choose']))
{
 
// I found "findme"
 // ... let's do some code

Reply With Quote
  #3  
Old 06-30-2010, 06:58 PM
wpeloquin wpeloquin is offline
 
Join Date: May 2006
Location: Behind you...
Posts: 143
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What exactly would this be for?
Reply With Quote
  #4  
Old 07-30-2011, 05:03 PM
vbresults vbresults is offline
 
Join Date: Apr 2009
Posts: 687
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is to finish an incomplete implementation of the 'arrayinteger' and 'arrayfree' option data types. It's vB 4.1.5 now and this still is not finished in the core. Absolutely ridiculous.
Reply With Quote
  #5  
Old 07-31-2011, 03:02 PM
Buray Savas ANI Buray Savas ANI is offline
 
Join Date: Jul 2011
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for job, but i dont understand, if we have vbseo this is good or not good?
Reply With Quote
  #6  
Old 09-26-2011, 10:10 AM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i was going to post this bug, but found ur thread..
its disappointing that it is not fix yet in main core files. have to create now a new admincp page for one setting.
Reply With Quote
  #7  
Old 01-17-2012, 05:24 PM
grasshoper grasshoper is offline
 
Join Date: Nov 2011
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is it fixed by now in 4.10?
Reply With Quote
Reply


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 02:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07498 seconds
  • Memory Usage 2,378KB
  • Queries Executed 21 (?)
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
  • (16)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)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
  • (6)postbit
  • (1)postbit_attachment
  • (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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete