Jump to content

WHMCSv7 auto update: what happens if you use a custom admin folder.?


Recommended Posts

Hi guys,

 

First of all, I am very excited about the newest auto update feature. However, I am afraid I got a bit too excited, since it hasn't been mentioned anywhere: what happens if you use a custom admin folder? Or only use two or three languages at a time, instead of all of them? How does WHMCSv7 handle that when it runs an automatic update?

 

Thanks!

Link to comment
Share on other sites

First of all, I am very excited about the newest auto update feature. However, I am afraid I got a bit too excited, since it hasn't been mentioned anywhere: what happens if you use a custom admin folder?

hmm interesting... I assume because you're running the updater from the admin area, it will know the location of the custom admin folder... or it takes it from the configuration.php file - one of the WHMCS guys should be able to give you a definitive answer.

Link to comment
Share on other sites

I can confirm the Automatic Updater is designed to handle custom admin directory names.

 

-Eddy

 

Hi Eddy,

 

Thanks for clarifying. Can you also tell us a little more about this below?

 

Does the auto updater understand:

 

- If you have moved /cron/ folder to a different location?

- If you are using only a couple of languages instead of all of them in the client area?

 

Thats it so far. If anyone has something to add, feel free to comment.

Link to comment
Share on other sites

The Automatic Updater has been designed to handle multiple types of environments including those with Cron folders in different locations and other languages as well.

I may be wrong, but I think the implication of the question is that on his v6 setup. he's removed the languages (I assume by deleting from the 'lang' folder) that he doesn't want to show in the client area... so if he has only english.php and dutch.php in the folder, I think he's wondering what happens if he upgrades to v7 - does the updater consider the other (deleted) language files to be missing and upload them... or does it just update the languages that are already there. :?:

 

i've no idea of the answer! :)

Link to comment
Share on other sites

I can confirm that if you delete some of the client area language files, an automatic update would reintroduce them when performing an update.

 

-Eddy

Which I think it should not. It should either read what files are in the directory, or you should be able to select/deselect active languages from the admin menu :) That way an update won't suddenly introduce a bunch of new languages :P

Link to comment
Share on other sites

WHMCS should give us the ability to remove the default languages by a simple hook (hey !brian, could you write that for us?) or by creating an option in the admin panel to disable the languages.

if you're thinking just in terms of the language selection in the header, then you could simplify that with a simple hook - to either remove or show specific language(s) only...

 

e.g let's say you wanted to only show Dutch, English & French languages in the client area selector, you could use the following hook...

 

<?php

function locales_hook($vars) {

   $mylocal = $vars['locales'];

   foreach ($mylocal as $key => $value) { 
       if ($value["language"] != "english" && $value["language"] != "french" && $value["language"] != "dutch") {
           unset($mylocal[$key]); 
       }
   }

   return array("locales" => $mylocal);
}
add_hook("ClientAreaPage", 1, "locales_hook");
?>

that would only show the three selected languages...

Bp8HLeY.png

 

if you wanted to do the opposite and show all languages, apart from Dutch, English & French, then you would do this...

 

<?php

function locales_hook($vars) {

   $mylocal = $vars['locales'];

   foreach ($mylocal as $key => $value) { 
       if ($value["language"] == "english" || $value["language"] == "french" || $value["language"] == "dutch") {
           unset($mylocal[$key]); 
       }
   }

   return array("locales" => $mylocal);
}
add_hook("ClientAreaPage", 1, "locales_hook");
?>

as an aside, if you only had a few languages to show in the client area, you could tweak the header & js code and use flag icons instead... though whether that's applicable to your situation would depend on which languages are chosen and whether you could legitimately display a representative flag icon for that language (e.g Arabic).

QIH5cwK.png

 

the above hooks only deal with the language selection in the "six" template - tested on a v7 dev installation, but i've no reason to believe it wouldn't work on v6... if you were using the "five" template, you would need to change a different variable.

 

also, this basic hook wouldn't prevent someone from adding a different language value in a URL - e.g 'demo.whmcs.com/index.php?language=spanish' to bypass the language selector - I daresay that could be blocked by either expanding the hook or using htaccess - but only someone with whmcs knowledge would know about the url language option.

Link to comment
Share on other sites

  • 2 months later...
Is it me or it simply doesn't work? I have enabled your hook by inserting the above code in /includes/hooks using WHMCS 7.1.1 with ?systpl=six to be sure it isn't my template breaking your hook. All languages are still showing up.

just tried it on a v7.1.1 dev (PHP v5.6), using "Six" template and it works fine... :idea:

 

<?php

function locales_hook($vars) {

   $mylocal = $vars['locales'];

   foreach ($mylocal as $key => $value) { 
       if ($value["language"] != "english" && $value["language"] != "spanish" && $value["language"] != "dutch") {
           unset($mylocal[$key]); 
       }
   }

   return array("locales" => $mylocal);
}
add_hook("ClientAreaPage", 1, "locales_hook");
?>

 

md8nlUg.png

 

I seem to recall reading somewhere that PHP 7 handles foreach loops differently, so it's possible if you're trying this on PHP7, the hook code may fail (though i've personally not seen it happen).

 

you could try changing the above foreach loop for the code below and see if it helps...

 

    foreach ($mylocal as $key => &$value) { 
       if ($value["language"] != "english" && $value["language"] != "spanish" && $value["language"] != "dutch") {
           unset($mylocal[$key]); 
       }
   }

other than that, you could add {debug} to the template to see if the hook is modifying the locales array...

Link to comment
Share on other sites

Doesn't work for me. I have tried the following:

 

- Temporarily remove all hooks, except yours (duh :) )

- Deactivate modules

- Use the default SIX template

 

I can confirm your code works on a fresh installation, though.

it's weird that it doesn't work on an old installation (even after cleaning) only a fresh one... i'd have almost preferred if you had told me it doesn't work full stop, but if it works on a clean installation, then the code is basically ok - there must be something else on your server preventing it from working. :?:

 

you might have to use the old-fashioned method and just delete the languages files you don't want - and after an update, remove them again. :roll:

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