Skip to content

Instantly share code, notes, and snippets.

@skurvish
Created September 4, 2014 11:03
Show Gist options
  • Save skurvish/6d9ba9b273a98f947735 to your computer and use it in GitHub Desktop.
Save skurvish/6d9ba9b273a98f947735 to your computer and use it in GitHub Desktop.
How to get DocMan Version
function get_docman_ver( &$majDMver, &$minDMver) {
$maj = $min = 0;
if ( file_exists(JPATH_BASE . '/administrator/components/com_docman/version.php') ) {
include_once( JPATH_BASE . '/administrator/components/com_docman/version.php' );
sscanf( ComDocmanVersion::getVersion(), "%i.%i", $maj, $min);
} else {
if ( file_exists(JPATH_BASE . '/administrator/components/com_docman/includes/defines.php') ) {
include_once( JPATH_BASE . '/administrator/components/com_docman/includes/defines.php' );
sscanf( _DM_VERSION, "%i.%i", $maj, $min);
} else // Unknown DocMan or not installed
return FALSE;
}
$majDMver = $maj;
$minDMver = $min;
return TRUE;
}
@johanjanssens
Copy link

if(JComponentHelper::getComponent('com_docman', true))
{
    if(defined('_DM_VERSION')) {
        $version = _DM_VERSION;
    } else {
        $version = ComDocmanVersion::VERSION;
    }
}

To check the version against a pre-defined version in your code you can use http://php.net/manual/en/function.version-compare.php

Example

if(version_compare($version, '2.0.0') >= 0) {
   //You are using DOCman 2.0+
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment