vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [vB4] Unfinished Settings - fix to work (https://vborg.vbsupport.ru/showthread.php?t=233327)

Coroner 01-16-2010 10:00 PM

[vB4] Unfinished Settings - fix to work
 
1 Attachment(s)
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

Coroner 01-18-2010 04:29 AM

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



wpeloquin 06-30-2010 06:58 PM

What exactly would this be for?

vbresults 07-30-2011 05:03 PM

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.

Buray Savas ANI 07-31-2011 03:02 PM

Thank you for job, but i dont understand, if we have vbseo this is good or not good?

Badshah93 09-26-2011 10:10 AM

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.

grasshoper 01-17-2012 05:24 PM

Is it fixed by now in 4.10?


All times are GMT. The time now is 07:48 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.01334 seconds
  • Memory Usage 1,837KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (16)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete