<?php
/**
 * Plugins module
 * 
 * Default module index file
 * 
 * @package linea21\core\plugins
 * @author $Author$ - linea21 <info@linea21.com>
 * @version $Id$ 
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

//////////// Check Droits utilisateur ////////////
if (!$l21auth->isSuperAdmin()) ReloadIndex('admin');
////////////

$todopage=$dir."/";

if(isset($_REQUEST['current']) && in_array($_REQUEST['current'], availablePlugins())) {

  $name = $_REQUEST['current'];

  $plug = new plugin($name);
  if(!$plug->is_active()) die("The plugin is currently disabled. Please, enable it before accessing the page.");

  // we include all plugin files
  //  $plug->loadPlugin($name);
  //  _debug(sprintf('Delegates to %s plugin.', $name));

  $todopage.=$name.'/index.php';

} else {

  if(isset($_REQUEST['name'])) $name = $_REQUEST['name'];

  switch ($todo)
  {
    case 'enable':
      $plug = new plugin($name);
      $plug->enable();
      header("Location: index.php?rub=plugins");
      break;
    case 'disable':
      $plug = new plugin($name);
      $plug->disable();
      header("Location: index.php?rub=plugins");
      break;
    case 'list':
      $todopage.="list.php";
      break;
    default:
      $todopage.="list.php";
  }
}
include_once(override($todopage, THEME_ADMIN_PATH));
?>