* Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2010 Regis Houssin * Copyright (C) 2015 Raphaƫl Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/public/demo/index.php * \ingroup core * \brief Entry page to access demo */ define("NOLOGIN", 1); // This means this output page does not require to be logged. define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. require '../../main.inc.php'; require_once '../../core/lib/functions2.lib.php'; $langs->loadLangs(array("main", "install", "other")); $conf->dol_hide_topmenu=GETPOST('dol_hide_topmenu', 'int'); $conf->dol_hide_leftmenu=GETPOST('dol_hide_leftmenu', 'int'); $conf->dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen', 'int'); $conf->dol_no_mouse_hover=GETPOST('dol_no_mouse_hover', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); // Security check global $dolibarr_main_demo; if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page', 0, 0, 1); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $res=$hookmanager->initHooks(array('demo')); $demoprofiles=array(); $alwayscheckedmodules=array(); $alwaysuncheckedmodules=array(); $alwayshiddencheckedmodules=array(); $alwayshiddenuncheckedmodules=array(); $url=''; $url.=($url?'&':'').($conf->dol_hide_topmenu?'dol_hide_topmenu='.$conf->dol_hide_topmenu:''); $url.=($url?'&':'').($conf->dol_hide_leftmenu?'dol_hide_leftmenu='.$conf->dol_hide_leftmenu:''); $url.=($url?'&':'').($conf->dol_optimize_smallscreen?'dol_optimize_smallscreen='.$conf->dol_optimize_smallscreen:''); $url.=($url?'&':'').($conf->dol_no_mouse_hover?'dol_no_mouse_hover='.$conf->dol_no_mouse_hover:''); $url.=($url?'&':'').($conf->dol_use_jmobile?'dol_use_jmobile='.$conf->dol_use_jmobile:''); $url=DOL_URL_ROOT.'/index.php'.($url?'?'.$url:''); $tmpaction = 'view'; $parameters=array(); $object=new stdClass(); $reshook=$hookmanager->executeHooks('addDemoProfile', $parameters, $object, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; if (empty($reshook)) { $demoprofiles=array( array('default'=>'1', 'key'=>'profdemoservonly','label'=>'DemoCompanyServiceOnly', 'disablemodules'=>'adherent,barcode,cashdesk,don,expedition,externalsite,ftp,incoterm,mailmanspip,margin,prelevement,product,productbatch,stock', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot8.png', 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-service.jpg', 'url'=>$url ), array('default'=>'-1','key'=>'profdemoshopwithdesk','label'=>'DemoCompanyShopWithCashDesk', 'disablemodules'=>'adherent,don,externalsite,ficheinter,ftp,incoterm,mailmanspip,prelevement,product,productbatch,stock', 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot2.png', 'url'=>$url ), array('default'=>'0', 'key'=>'profdemoprodstock','label'=>'DemoCompanyProductAndStocks', 'disablemodules'=>'adherent,contrat,don,externalsite,ficheinter,ftp,mailmanspip,prelevement,service', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot2.png', 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-product.jpg', 'url'=>$url ), array('default'=>'-1', 'key'=>'profdemofun','label'=>'DemoFundation', 'disablemodules'=>'banque,barcode,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,ficheinter,ftp,incoterm,mailmanspip,margin,prelevement,product,productbatch,projet,propal,propale,service,societe,stock,tax', 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png', 'url'=>$url ), array('default'=>'0', 'key'=>'profdemofun2','label'=>'DemoFundation2', 'disablemodules'=>'barcode,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,ficheinter,ftp,incoterm,mailmanspip,margin,prelevement,product,productbatch,projet,propal,propale,service,societe,stock,tax', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png', 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-foundation.jpg', 'url'=>$url ), // All demo profile array('default'=>'0', 'key'=>'profdemoall','label'=>'ChooseYourDemoProfilMore', 'disablemodules'=>'adherent,don,externalsite,mailmanspip,takepos', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot9.png' 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-all.jpg' ) ); // Visible $alwayscheckedmodules=array('barcode','bookmark','categorie','externalrss','fckeditor','geoipmaxmind','gravatar','memcached','syslog','user','webservices'); // Technical module we always want $alwaysuncheckedmodules=array('dav','dynamicprices','incoterm','loan','multicurrency','paybox','paypal','stripe','google','printing','scanner','skype','website'); // Module we dont want by default // Not visible $alwayshiddencheckedmodules=array('accounting','api','barcode','blockedlog','bookmark','clicktodial','comptabilite','cron','document','domain','externalrss','externalsite','fckeditor','geoipmaxmind','gravatar','label','ldap', 'mailmanspip','notification','oauth','syslog','user','webservices','workflow', // Extended modules 'memcached','numberwords','zipautofillfr'); $alwayshiddenuncheckedmodules=array('debugbar','emailcollector','ftp','hrm','modulebuilder','webservicesclient','websites', // Extended modules 'awstats','bittorrent','bootstrap','cabinetmed','cmcic','concatpdf','customfield','deplacement','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','multicompany','nltechno','numberingpack','openstreetmap', 'ovh','phenix','phpsysinfo','pibarcode','postnuke','selectbank','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail'); } // Search modules $dirlist=$conf->file->dol_document_root; // Search modules dirs $modulesdir = dolGetModulesDirs(); $filename = array(); $modules = array(); $orders = array(); $categ = array(); $dirmod = array(); $i = 0; // is a sequencer of modules found $j = 0; // j is module number. Automatically affected if module number not defined. foreach ($modulesdir as $dir) { // Charge tableaux modules, nom, numero, orders depuis repertoire dir $handle=@opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle))!==false) { //print "$i ".$file."\n
"; if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); if ($modName) { try { include_once $dir.$file; $objMod = new $modName($db); if ($objMod->numero > 0) { $j = $objMod->numero; } else { $j = 1000 + $i; } $modulequalified=1; // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->$const_name)) $modulequalified=0; if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && empty($conf->global->$const_name)) $modulequalified=0; if ($modulequalified) { $modules[$i] = $objMod; $filename[$i]= $modName; $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; $dirmod[$i] = $dirroot; $j++; $i++; } } catch(Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } } } } } } asort($orders); //var_dump($orders); /* * Actions */ if (GETPOST('action', 'aZ09') == 'gotodemo') // Action run when we click on "Start" after selection modules { //print 'ee'.GETPOST("demochoice"); $disablestring=''; // If we disable modules using a profile choice if (GETPOST("demochoice")) { foreach ($demoprofiles as $profilearray) { if ($profilearray['key'] == GETPOST("demochoice")) { $disablestring=$profilearray['disablemodules']; break; } } } // If we disable modules using personalized list foreach($modules as $val) { $modulekeyname=strtolower($val->name); if (empty($_POST[$modulekeyname]) && empty($val->always_enabled) && ! in_array($modulekeyname, $alwayscheckedmodules)) { $disablestring.=$modulekeyname.','; if ($modulekeyname=='propale') $disablestring.='propal,'; } } // Do redirect to login page if ($disablestring) { if (GETPOST('urlfrom')) $url.=(preg_match('/\?/', $url)?'&':'?').'urlfrom='.urlencode(GETPOST('urlfrom', 'alpha')); $url.=(preg_match('/\?/', $url)?'&':'?').'disablemodules='.$disablestring; //var_dump($url);exit; header("Location: ".$url); exit; } } /* * View */ $head=''; $head.=''."\n"; $head.=''."\n"; $head.=' '; llxHeaderVierge($langs->trans("DolibarrDemo"), $head); print "\n"; print '
'; print '
'; print ''; print '
'; print '
'; print '
'; print '
'; print '
'.$langs->trans("DemoDesc").'

'; print '
'.$langs->trans("ChooseYourDemoProfil").'
'; print '
'; print '
'; print '
'; print '
'; $i=0; foreach ($demoprofiles as $profilearray) { if ($profilearray['default'] >= 0) { //print $profilearray['lang']; if (! empty($profilearray['lang'])) $langs->load($profilearray['lang']); $url=$_SERVER["PHP_SELF"].'?action=gotodemo'; $urlwithmod=$url.'&demochoice='.$profilearray['key']; // Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr' //print "xx".$_SERVER["PHP_SELF"].' '.DOL_URL_ROOT.'
'; $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/i', '', $_SERVER["PHP_SELF"]); //print $urlfrom; if (! empty($profilearray['url'])) { $urlwithmod=$profilearray['url']; $urlwithmod=$urlwithmod.(preg_match('/\?/', $urlwithmod)?'&':'?').'urlfrom='.urlencode($urlfrom); if (! empty($profilearray['disablemodules'])) { $urlwithmod=$urlwithmod.(preg_match('/\?/', $urlwithmod)?'&':'?').'disablemodules='.$profilearray['disablemodules']; } } if (empty($profilearray['url'])) { print '
'; } print '
'."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print '
'."\n"; print '
'; print ''; print '
'; print 'Demo '.$profilearray['label'].''; print '
'; print '
'; print $langs->trans($profilearray['label']); print '
'; print '
'; print '
'; // Modules (a profile you must choose modules) if (empty($profilearray['url'])) { print ''; } print '
'; print '
'."\n"; $i++; } } print '
'; // TODO Replace this with a hook // Google Adsense (need Google module) if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { if (empty($conf->dol_use_jmobile)) { print '
'."\n"; print ''."\n"; print ''."\n"; print '
'."\n"; } else { print ''."\n"; } } llxFooterVierge(); $db->close(); /** * Show header for demo * * @param string $title Title * @param string $head Head string * @return void */ function llxHeaderVierge($title, $head = "") { global $user, $conf, $langs; top_httphead(); top_htmlhead($head, $title, 0, 0, array(), array('public/demo/demo.css')); print '
'."\n"; } /** * Show footer for demo * * @return void */ function llxFooterVierge() { printCommonFooter('public'); print "\n"; print "
\n"; print "\n"; }