Query not writing
#5
(2017-07-30, 01:30 AM)Whiteneo Wrote:
// Reset
function random_reset() {
  global $mybb, $db;
if ($mybb->settings['random_reset'] == 1){
$db->write_query("UPDATE ".TABLE_PREFIX."settings SET value='' WHERE name='random_userbar'");
$db->write_query("UPDATE ".TABLE_PREFIX."settings SET value='1' WHERE name='random_uid'");
$db->write_query("UPDATE ".TABLE_PREFIX."settings SET value='0' WHERE name IN('random_enable', 'random_reset')");
rebuild_settings();
}
}

This should be the right code.

other removed stuff is not necesary due you have to rebuild settings file on install or activate function.

Cheers...

I do not know what do you whant to do, but without the entire code who can knows what do you wanna do, only you Smile

Still not working. the function random_reset is meant to basically reset the plugin settings page to default values when the yesno random_reset option has the value of 1 (yes). Here's the full code:

<?php
if(!defined("IN_MYBB"))
{
    die("You Cannot Access This File Directly. Please Make Sure IN_MYBB Is Defined.");
} 

// Hooks
$plugins->add_hook('global_start', 'random_global_start'); 
$plugins->add_hook('admin_user_groups_add', 'random_activate'); 

function random_info()
{
return array(
        "name"  => "Random Userbar Game",
        "description"=> "Steal a userbar from someone when repping them",
        "website"        => "http://softwaysandre.com",
        "author"        => "Wires",
        "authorsite"    => "http://softwaysandre.com",
        "version"        => "1.0",
        "guid"             => "",
        "compatibility" => "18*"
    );
} 
// Activate
function random_activate() {
global $db;

$random_group = array(
        'gid'    => 'NULL',
        'name'  => 'random',
        'title'      => 'Random Userbar Game',
        'description'    => 'Settings For My First Plugin',
        'disporder'    => "1",
        'isdefault'  => "0",
    ); 

$db->insert_query('settinggroups', $random_group);
 $gid = $db->insert_id(); 

$random_setting_1 = array(
        'sid'            => 'NULL',
        'name'        => 'random_enable',
        'title'            => 'Power on?',
        'description'    => 'If you set this option to yes, this plugin be active on your board.',
        'optionscode'    => 'yesno',
        'value'        => '0',
        'disporder'        => 1,
        'gid'            => intval($gid),
    ); 

$random_setting_2 = array(
        'sid'            => 'NULL',
        'name'        => 'random_userbar',
        'title'            => 'Userbar URL',
        'description'    => 'Set IMG url to userbar',
        'optionscode'    => 'text',
        'value'        => '',
        'disporder'        => 2,
        'gid'            => intval($gid),
    ); 
    
$random_setting_3 = array(
        'sid'            => 'NULL',
        'name'        => 'random_reset',
        'title'            => 'Reset',
        'description'    => 'Reset and rebuild settings page.',
        'optionscode'    => 'yesno',
        'value'        => '0',
        'disporder'        => 4,
        'gid'            => intval($gid),
    ); 
    
$random_setting_4 = array(
        'sid'            => 'NULL',
        'name'        => 'random_uid',
        'title'            => 'Set UID',
        'description'    => 'Give a user the userbar to begin with.',
        'optionscode'    => 'text',
        'value'        => '',
        'disporder'        => 3,
        'gid'            => intval($gid),
    ); 
    
// Create usergroup
$random_create_group = array(
        'type'            => '1',
        'title'            => 'Lucky Usergroup',
        'description'    => 'You stole the userbar.',
        'namestyle'    => '{username}',
        'usertitle'        => '',
        'stars'         => '0',
        'starimage'         => 'images/stars.png',
        'image'        => 'test',
        'disporder'        => 0,
        'isbannedgroup'        => 0,
        'canview'        => 1,
        'canviewthreads'        => 1,
        'canviewprofiles'        => 1,
        'candlattachments'        => 1,
        'canviewboardclosed'        => 0,
        'canpostthreads'        => 1,
        'canpostreplys'        => 1,
        'canpostattachments'        => 1,
        'canratethreads'        => 1,
        'modposts'        => 0,
        'modthreads'        => 0,
        'mod_edit_posts'        => 0,
        'modattachments'        => 0,
        'caneditposts'        => 1,
        'candeleteposts'        => 1,
        'candeletethreads'        => 1,
        'caneditattachments'        => 1,
        'canviewdeletionnotice'        => 1,
        'canpostpolls'        => 1,
        'canvotepolls'        => 1,
        'canundovotes'        => 0,
        'canusepms'        => 1,
        'cansendpms'        => 1,
        'cantrackpms'        => 1,
        'candenypmreceipts'        => 1,
        'pmquota'        => '200',
        'maxpmreceipients'        => '5',
        'cansendemail'        => 1,
        'cansendemailoverride'        => 0,
        'maxemails'        => '5',
        'emailfloodtime'        => '5',
        'canviewmemberlist'        => 1,
        'canviewcalender'        => 1,
        'canaddevents'        => 1,
        'canbypasseventmod'        => 0,
        'canmoderateevents'        => 0,
        'canviewonline'        => 1,
        'canviewwolinvis'        => 0,
        'canviewonlineips'        => 0,
        'cancp'        => 0,
        'issupermod'        => 0,
        'cansearch'        => 1,
        'canusercp'        => 1,
        'canuploadavatars'        => 1,
        'canratemembers'        => 1,
        'canchangename'        => 0,
        'canbereported'        => 1,
        'canchangewebsite'        => 1,
        'showforumteam'        => 0,
        'usereputationsystem'        => 1,
        'cangivereputations'        => 1,
        'candeletereputations'        => 1,
        'reputationpower'        => '1',
        'maxreputationsday'        => '5',
        'maxreputationsperuser'        => '0',
        'maxreputationsperthread'        => '0',
        'candisplaygroup'        => 1,
        'attachquota'        => '0',
        'cancustomtitle'        => 1,
        'canwarnusers'        => 0,
        'canreceivewarnings'        => 1,
        'maxwarningsday'        => '0',
        'canmodcp'        => 0,
        'showinbirthdaylist'        => 1,
        'canoverridepm'        => 0,
        'canusesig'        => 1,
        'canusesigxposts'        => 0,
        'signofollow'        => 0,
        'canedittimelimit'        => 0,
        'maxposts'        => 0,
        'showmemberlist'        => 1,
        'canmanageannounce'        => 0,
        'canmanagemodqueue'        => 0,
        'canmanagereporedcontent'        => 0,
        'canviewmodlogs'        => 0,
        'caneditprofiles'        => 0,
        'canbanusers'        => 0,
        'canviewwarnlogs'        => 0,
        'canuseipsearch'        => 0,
        'gid'            => intval($gid),
    );
    
$db->insert_query('settings', $random_setting_1);
$db->insert_query('settings', $random_setting_2);
$db->insert_query('settings', $random_setting_3);
$db->insert_query('settings', $random_setting_4);
$db->insert_query('usergroups', $random_create_groups);
  rebuild_settings();
} 
// Disable
function random_deactivate()
  {
  global $db;
 $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('random_enable', 'random_userbar', 'random_reset', 'random_uid')");
    $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='random'");
rebuild_settings();
    $db->query("DELETE FROM ".TABLE_PREFIX."usergroups WHERE title='Lucky Usergroup'");
rebuild_settings();
 } 
 // Start Hook
 function random_global_start(){
global $mybb;

if ($mybb->settings['random_enable'] == 1){
 echo "My first plugin works!";
}
} 
// Reset
function random_reset() {
  global $mybb, $db;
if ($mybb->settings['random_reset'] == 1){
$db->write_query("UPDATE ".TABLE_PREFIX."settings SET value='' WHERE name='random_userbar'");
$db->write_query("UPDATE ".TABLE_PREFIX."settings SET value='1' WHERE name='random_uid'");
$db->write_query("UPDATE ".TABLE_PREFIX."settings SET value='0' WHERE name IN('random_enable', 'random_reset')");
rebuild_settings();
}
}
// Give userbar to UID

?>

Both the create groups function and random_reset function doesn't seem to work.
Plugin Count: I lost count.
Public Plugins are available here.
Please do not PM me for support unless asked to.
Reply


Messages In This Thread
Query not writing - by Wires - 2017-07-29, 10:11 PM
RE: Query not writing - by Whiteneo - 2017-07-30, 01:05 AM
RE: Query not writing - by Wires - 2017-07-30, 01:22 AM
RE: Query not writing - by Whiteneo - 2017-07-30, 01:30 AM
RE: Query not writing - by Wires - 2017-07-30, 02:07 AM
RE: Query not writing - by fizz - 2017-07-30, 08:12 AM
RE: Query not writing - by Wires - 2017-07-30, 10:17 AM
RE: Query not writing - by chack1172 - 2017-07-30, 10:27 AM
RE: Query not writing - by Wires - 2017-07-30, 10:31 AM
RE: Query not writing - by fizz - 2017-07-30, 11:49 AM
RE: Query not writing - by Wires - 2017-07-30, 12:03 PM
RE: Query not writing - by Whiteneo - 2017-07-30, 06:35 PM
RE: Query not writing - by Wires - 2017-07-31, 03:33 AM
RE: Query not writing - by Whiteneo - 2017-07-31, 03:50 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)