Exemplo n.º 1
0
/**
 *  Enable a module
 *  @param      value       Name of module to activate
 *  @param      withdeps    Activate/Disable also all dependencies
 *  @return     string      Error message or '';
 */
function Activate($value,$withdeps=1)
{
    global $db, $modules, $langs, $conf;

    $modName = $value;

    $ret='';

    // Activate module
    if ($modName)
    {
        $modFile = $modName . ".class.php";

        // Loop on each directory
        $found=false;
    	foreach ($conf->file->dol_document_root as $type => $dirroot)
        {
            $modulesdir[] = $dirroot."/includes/modules/";
            
            if ($type == 'alt')
			{	
				$handle=@opendir($dirroot);
				if (is_resource($handle))
				{
					while (($file = readdir($handle))!==false)
					{
					    if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
					    {
					    	if (is_dir($dirroot . '/' . $file . '/includes/modules/'))
					    	{
					    		$modulesdir[] = $dirroot . '/' . $file . '/includes/modules/';
					    	}
					    }
					}
					closedir($handle);
				}
			}
        }

        foreach ($modulesdir as $dir)
        {
        	if (file_exists($dir.$modFile))
        	{
        		$found=@include_once($dir.$modFile);
        		if ($found) break;
        	}
        }

        $objMod = new $modName($db);

        // Test if PHP version ok
        $verphp=versionphparray();
        $vermin=isset($objMod->phpmin)?$objMod->phpmin:0;
        if (is_array($vermin) && versioncompare($verphp,$vermin) < 0)
        {
            return $langs->trans("ErrorModuleRequirePHPVersion",versiontostring($vermin));
        }

        // Test if Dolibarr version ok
        $verdol=versiondolibarrarray();
        $vermin=isset($objMod->need_dolibarr_version)?$objMod->need_dolibarr_version:0;
        //print 'eee'.versioncompare($verdol,$vermin).join(',',$verdol).' - '.join(',',$vermin);exit;
        if (is_array($vermin) && versioncompare($verdol,$vermin) < 0)
        {
            return $langs->trans("ErrorModuleRequireDolibarrVersion",versiontostring($vermin));
        }

        // Test if javascript requirement ok
        if (! empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax))
        {
            return $langs->trans("ErrorModuleRequireJavascript");
        }

        $result=$objMod->init();
        if ($result <= 0) $ret=$objMod->error;
    }

    if (! $ret && $withdeps)
    {
        if (is_array($objMod->depends) && !empty($objMod->depends))
        {
            // Activation des modules dont le module depend
            for ($i = 0; $i < sizeof($objMod->depends); $i++)
            {
                if (file_exists(DOL_DOCUMENT_ROOT."/includes/modules/".$objMod->depends[$i].".class.php"))
                {
                    Activate($objMod->depends[$i]);
                }
            }
        }

        if (isset($objMod->conflictwith) && is_array($objMod->conflictwith))
        {
            // Desactivation des modules qui entrent en conflit
            for ($i = 0; $i < sizeof($objMod->conflictwith); $i++)
            {
                if (file_exists(DOL_DOCUMENT_ROOT."/includes/modules/".$objMod->conflictwith[$i].".class.php"))
                {
                    UnActivate($objMod->conflictwith[$i],0);
                }
            }
        }
    }

    return $ret;
}
Exemplo n.º 2
0
$langs->load("admin");

$mode=isset($_GET["mode"])?GETPOST("mode"):(isset($_SESSION['mode'])?$_SESSION['mode']:0);
$mesg=GETPOST("mesg");

if (!$user->admin)
    accessforbidden();


/*
 * Actions
 */

if (isset($_GET["action"]) && $_GET["action"] == 'set' && $user->admin)
{
    $result=Activate($_GET["value"]);
    $mesg='';
    if ($result) $mesg=$result;
    Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
	exit;
}

if (isset($_GET["action"]) && $_GET["action"] == 'reset' && $user->admin)
{
    $result=UnActivate($_GET["value"]);
    $mesg='';
    if ($result) $mesg=$result;
    Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
	exit;
}
Exemplo n.º 3
0
				// If we ask to force some modules to be enabled
				if (! empty($force_install_module))
				{
					if (! defined('DOL_DOCUMENT_ROOT') && ! empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT',$dolibarr_main_document_root);
					if (! defined('DOL_DOCUMENT_ROOT_ALT') && ! empty($dolibarr_main_document_root_alt)) define('DOL_DOCUMENT_ROOT_ALT',$dolibarr_main_document_root_alt);

					$tmparray=explode(',',$force_install_module);
					foreach ($tmparray as $modtoactivate)
					{
						$modtoactivatenew=preg_replace('/\.class\.php$/i','',$modtoactivate);
                        $file=$modtoactivatenew.'.class.php';
						dolibarr_install_syslog('install/etape5.php Activate module file='.$file);
                        $res=dol_include_once("/includes/modules/".$file);

                        $res=Activate($modtoactivatenew,1);
                        if (! $result) print 'ERROR in activating module file='.$file;
					}
				}

				dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_DEBUG);
				$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'");
				if (! $resql) dol_print_error($db,'Error in setup program');

				$db->commit();
			}
		}
		else
		{
			print $langs->trans("ErrorFailedToConnect")."<br>";
		}
Exemplo n.º 4
0
echo img_domain;
?>
/nav/image_07.jpg" width="29" height="535"></TD>
		<TD ROWSPAN=13 width="600" colspan="4" bgcolor="#000000" valign="top" height="720">

	<?php 
// ДАЛЕЕ ИДЕТ ОСНОВНОЙ ЭКРАН КОТОРЫЙ БУДЕМ ЗАПОЛНЯТЬ  В ЗАВИСИМОСТИ ОТ ВЫБРАННЫХ ОПЦИЙ
switch ($option) {
    case 'for':
        ForgetPassword();
        break;
    case 'reg':
        EndRegistration();
        break;
    case 'activate':
        Activate();
        break;
    case 'register':
        BeginRegistration();
        break;
    case 'history':
        History();
        break;
    default:
        ?>

  <table summary="" border="0" cellpadding="0" cellspacing="0"  width="560" style="height:23">
	<TR>
		<TD ROWSPAN=5 width="216" height="21" valign="top">
			<div style="position: relative;">
			<IMG SRC="http://<?php