Jump to content

Licensing Module Configurations


mfoland

Recommended Posts

Hey guys,

 

I am working on setting up a special feature to show enabled productive addons on a licenseinfo.php

 

Thus far, I have separated the values of the active addons since I had two fake ones in my product called Premium Product and Branding Removal. The Branding Removal will become a real available addon. For the sake of testing 2 different addons, I added the Premium Product addon.

 

So in the if ($results['status'] == "Active") {

I added THIS: 

$results['checkdate'] = $checkdate;
	    $results['addons'] = str_replace("|", " \n", $results['addons']);
	    $results['addons'] = str_replace(";", " \n", $results['addons']);
	    $results['addons'] = str_replace("=", "= ", $results['addons']);

so in my echo it has each addon on a new line as defined by replace the " with the " \n" for new line.

 

The problem I'm running into is trying to make an array to pull the name of the addon out of the name= and display if status= Active. I'd like to make a php array loop for this. I have tried this to no avail.. including

$array = array("$results['addons']");
$length = count($array);
for ($i = 0; $i < $length; $i++) {
  print $array[$i];
}

Any guidance and support would be greatly appreciated 🙂 I'd like to have options show for if addon xyz is enabled, and obviously hide branding if branding removal is set to no. I'd set default branding for my product!

 

Thanks guys and gals! Any help from any of the guru would be appreciated as well!

Link to comment
Share on other sites

Quote

From @nhudson Oct 30th 2013 Licensing Addon: Parsing addons returned by the integration code

The addons are returned in the format "name=Addon Name;nextduedate=Next Due Date;status=Status|


So, from this, you can see that each addon data is separated by a |. You can explode this | to obtain each addon separately in the list.

Once you have done this, you can explode on ; to get separate variables with the separate options and then finally on the = symbol. This will then give you the addon name, next due date and status.

Something like:

$addonarray = array();

$addonslist = explode('|',$results['addons']);

foreach ($addonslist as $addons){

$addondata = explode(';',$addons);

$addonname = $addonnextduedate = $addonstatus = "";

foreach ($addondata as $addon){

$addonnvp = explode('=',$addon);

if($addonnvp[0] == 'name') $addonname = $addonnvp[1];

if($addonnvp[0] == 'nextduedate') $addonnextduedate = $addonnvp[1];

if($addonnvp[0] == 'status') $addonstatus = $addonnvp[1];

}

$addonarray[$addonname] = array("nextduedate"=>$addonnextduedate,"status"=>$addonstatus);

}

The code above assumes that each addon has a different name and is just a sample. You should create and check your own code to obtain the list in the format that you require.

$adName = array("$addonname");
$arrlength = count($adName);

for($x = 0; $x < $arrlength; $x++) {
    echo $adName[$x];
    echo "<br>";
$adName[$x] == "$hisAddon";
}

before the closing } to license.php

I was hoping that this would work on the licenseinfo.php page I'm doing, and it only echos via the addons via license.php. What am I missing? I tried doing the whole array on the licenseinfo.php but still no go. @nhudson's script does work though with license.php -- which is the sample_code.php for the license manager. I've been making several updates to the license call. Any help to get the $hisAddon, which is the $adName[$x] to show on my licenseinfo.php script would be great. Of course I AM including license.php as well.

Edited by mfoland
Edit to fix original quote
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