exit("");
}
$container = null;
$iloc = null;
$cloc = null;
if (isset($_POST['id'])) {
    $container = $db->selectObject("container", "id=" . intval($_POST['id']));
}
if ($container != null) {
    $iloc = unserialize($container->internal);
    $loc = unserialize($container->external);
    $cloc = unserialize($container->external);
    $cloc->int = $container->id;
}
if (exponent_permissions_check("add_module", $loc) || $iloc != null && exponent_permissions_check("administrate", $iloc) || $cloc != null && exponent_permissions_check("edit_module", $cloc)) {
    $container = container::update($_POST, $container, $loc);
    if (isset($container->id)) {
        $db->updateObject($container, "container");
    } else {
        $db->insertObject($container, "container");
    }
    if ($container->is_existing == 0) {
        $iloc = unserialize($container->internal);
        $locref = $db->selectObject("locationref", "module='" . $iloc->mod . "' AND source='" . $iloc->src . "'");
        $locref->description = isset($_POST['description']) ? $_POST['description'] : '';
        $db->updateObject($locref, "locationref", "module='" . $iloc->mod . "' AND source='" . $iloc->src . "'");
    }
    if (isset($_SESSION['containers_cache'])) {
        unset($_SESSION['containers_cache']);
    }
    exponent_flow_redirect();
 /**
  * used to create containers for new modules
  * @global db the exponent database object
  * @param  $iloc
  * @param  $m
  * @param bool $linked
  * @return void
  */
 private function add_container($iloc, $m, $linked = false)
 {
     global $db;
     if ($iloc->mod != 'contactmodule') {
         $iloc->mod = $this->new_modules[$iloc->mod];
         $m->internal = isset($m->internal) && strstr($m->internal, "Controller") ? $m->internal : serialize($iloc);
         $m->action = isset($m->action) ? $m->action : 'showall';
         $m->view = isset($m->view) ? $m->view : 'showall';
         if ($m->view == "Default") {
             $m->view = 'showall';
         }
     } else {
         // must be an old school contactmodule
         $iloc->mod = $this->new_modules[$iloc->mod];
         $m->internal = serialize($iloc);
     }
     if ($linked) {
         $newconfig = new expConfig();
         $config['aggregate'] = array($iloc->src);
         $newconfig->config = $config;
         $newmodule['i_mod'] = $iloc->mod;
         $newmodule['modcntrol'] = $iloc->mod;
         $newmodule['rank'] = $m->rank;
         $newmodule['views'] = $m->view;
         $newmodule['title'] = $m->title;
         $newmodule['actions'] = $m->action;
         $_POST['current_section'] = 1;
         $m = container::update($newmodule, $m, expUnserialize($m->external));
         $newmodinternal = expUnserialize($m->internal);
         $newmod = explode("Controller", $newmodinternal->mod);
         $newmodinternal->mod = $newmod[0];
         $newconfig->location_data = $newmodinternal;
         $newconfig->save();
     }
     $db->insertObject($m, 'container');
 }