Jump to content

AddOn Module Version


Recommended Posts

I'm a bit confused with version numbers and how to update them. Maybe because I've in mind how vBulletin keeps updates.

 

Let's say that my initial file has the code:

 

//     ########################  MODULE CONFIGURATION  ########################
   function forum_config() 
   {
       $configarray = array(
       "name" => "whmcsBB",
       "description" => "Community Bulletin Board",
       "version" => "1.0.0",
       "author" => "ChrisTERiS",
       "language" => "english",
       "fields" => array(
       ));
       return $configarray;
   }
//     ##########################  ACTIVATE MODULE  ###########################
function forum_activate()
{
.......... here SQL to create tables...............
}
//     #########################  DEACTIVATE MODULE  ##########################
function forum_deactivate()
{
......... here SQL to drop any database changes...........
}

 

That's works fine for initial installation, so no problem. Now let's come to update to version 1.1.0. The code is:

function forum_upgrade($version) 
{
   global $db;

   # Run SQL Updates for V1.0.0 to V1.1.0
   if ($version == '1.0.0') 
   {
       echo '1';
       // Settings
       mysqli_query($db,"ALTER TABLE mod_forum_settings ADD rating TINYINT(1) DEFAULT '1' NOT NULL");
       mysqli_query($db,"ALTER TABLE mod_forum_settings ADD social TINYINT(1) DEFAULT '1' NOT NULL");
       // Usergroups
       mysqli_query($db,"ALTER TABLE mod_forum_usergroups ADD forum_html TINYINT(1) DEFAULT '0' NOT NULL");
       // Update Version 
       mysqli_query($db,"UPDATE tbladdonmodules SET value='1.1.0' WHERE module='forum' AND setting='version'");
   }
}

........ and in function forum_output($vars) I've added.......................

//     ###########################  MODULE OUTPUT  ############################
function forum_output($vars)
{
.............................................
   // Version
   $version = $vars['version'];
   if($version <> '1.1.0')
   {
      $upgrade = forum_upgrade($version);
   }
..................

 

That's also works fine. Have checked the database and new fields appear to be there. My Questions are:

 

1.- When I'm updating a module, do I need (like with vBulletin) to update version number in function forum_config() or let it to version 1.0.0 as it was the initial release?

2.- Even if in database I can see in table tbladdonmodules that the mod got the new version (eg module='forum', setting='version', value='1.1.0', in Setup-> AddOns I'm still seeing the old version (1.0.0)

3.- Placing an echo command within function forum_upgrade($version)

function forum_upgrade($version) 
{
   global $db;

   # Run SQL Updates for V1.0.0 to V1.1.0
   if ($version == '1.0.0') 
   {
       echo '1';
   }
}

I can see that it always goes there. Am I doing something wrong?

 

Thank you

Chris

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated