3

I have a package which contains a component and other extensions.

How can I restrict the user not to install the component directly? In other words, if the user unzip the package and install the component directly I have to raise an error message.

Is this possible using scriptfile??

2

The problem is that Joomla installer itself unzips the package to install. So, there is no difference between an installation from a manual decompression or from an uploaded file. Only the installer knows if it must continue deleting the uncompressed files or not.

The only difference that you could detect is the files timestamp. For example, all files are created within ... 2-3 seconds from the current date, then it has been uploaded. With a bigger difference, it must be a manual unzipped package.

  • Thanks. I thought so and It makes sense for joomla itself uncompress the package and do individual extension install. I made a workaround and added that as one of the answer... – Malaiselvan Mar 12 '16 at 20:56
2

The workaround I am doing is by adding a session variable in package script file and check that in component script file.

If the session variable doesnt exist then the component installation will return false.

The code snippet is as below.

Script of package

class pkg_MyPackInstallerScript {
  public function preflight($route, JAdapterInstance $adapter){
    $session = JFactory::getSession();
    $session->set('ses_via_package',true);
  }
  .....
}

Script of component

class com_ComponentInstallerScript {

  public function preflight($route, JAdapterInstance $adapter){

    $session = JFactory::getSession();
    $from_package = $session->get('ses_via_package');
    $session->clear('ses_via_package');

    if(empty($from_package)){
      JError::raiseError( xxxx, 'Error message');
      return false;
    }

  }
 .....
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.