MyBB Community Forums

Full Version: Check what settings are set to?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Greetings.

I have the following code in my upcomming plugin.

But I want to make a code which can get the Terms of Service Version from the database.

Hope someone will be able to help me with this.

This is my code.
//All the activation processes go here
function tospopup_activate()
{
    global $db;

     $group = array(
        "gid"            => "NULL",
        "title"          => "Terms of Service Popup",
        "name"           => "tospopup",
        "description"    => "Settings for Terms of Service Popup.",
        "disporder"      => "1",
        "isdefault"      => "no",
    );
    
    $db->insert_query(TABLE_PREFIX."settinggroups", $group);
    $gid = $db->insert_id(); //This will get the id of the just added record in the db
    
    
    $setting_1 = array(
        "sid"            => "NULL",
        "name"           => "tospopup_setting",
        "title"          => "Terms of Service Version",
        "description"    => "What is your current Terms of Service Version. Change this version number to another number whenever you want to force your users to accept the new Terms of Service.",
        "optionscode"    => "text",
        "value"          => '1.0.0',
        "disporder"      => '1',
        "gid"            => intval($gid),
    );

    $db->insert_query(TABLE_PREFIX."settings", $setting_1);
    rebuildsettings();
}

//All deactivation processes go here
function tospopup_deactivate()
{
    global $db;

    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tospopup_setting'");
    $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tospopup'");
    rebuildsettings();
} 

if($mybb->settings['tospopup_setting'] == "1.0.0") {

//do something

}

(2011-11-09, 05:52 PM)Malcolm. Wrote: [ -> ]

if($mybb->settings['tospopup_setting'] == "1.0.0") {

//do something

}


Actually I want it to be able to do the something like this:
if($mybb->settings['tospopup_setting'] == "$version") {

//do something

}

NOTE: $version should be the version which is in the database.
Then define it what the version is. For example:

$version = $mybb->settings['your_version_setting'];

if($mybb->settings['tospopup_setting'] == "$version") {

//do something

} 

So it'd call it from current version. Note, you'll need to edit $mybb->settings to the place where you've stored your current version info.
in which database?

how are you going to force the user that is a guest to view the TOS? users are easy, but guests are more difficult to deal with without annoying them with multiple visits to the TOS.

also, whatever you figure out, store PHP friendly versions (X.Y.Z) like you are doing so far, thus you can use the PHP version_compare() function and "<" comparator
(2011-11-09, 08:34 PM)pavemen Wrote: [ -> ]in which database?

how are you going to force the user that is a guest to view the TOS? users are easy, but guests are more difficult to deal with without annoying them with multiple visits to the TOS.

also, whatever you figure out, store PHP friendly versions (X.Y.Z) like you are doing so far, thus you can use the PHP version_compare() function and "<" comparator

I only force users. Not the quests to do this.
then add a new field to the users tables to store the last version of the TOS the user visited. your plugin should hook into global_start and you can check the user's last version viewed and compare it to your current version, then send the user to the new page

before sending them to the new page you can update the users table with the new TOS version. or if your TOS page has an accept/agree button that form action could update the user table and then return to the site.
oh, and you should hook into the register code as well to update the user table with the latest TOS info they agree to when first registering