<?php
/**
 * @package linea21.core
 * @subpackage plugins
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @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: ".$_SERVER['HTTP_REFERER']);
      break;
    case 'disable':
      $plug = new plugin($name);
      $plug->disable();
      header("Location: ".$_SERVER['HTTP_REFERER']);
      break;
    case 'list':
      $todopage.="list.php";
      break;
    default:
      $todopage.="list.php";
  }
}
include_once(override($todopage, THEME_ADMIN_PATH));
?>