public function savePOSTsettings($post)
 {
     if (!empty($post['id'])) {
         $planid = $post['id'];
     } else {
         // Fake knowing the planid if is zero.
         $planid = $this->getMax() + 1;
     }
     if (isset($post['id'])) {
         unset($post['id']);
     }
     if (isset($post['inherited_micro_integrations'])) {
         unset($post['inherited_micro_integrations']);
     }
     if (!empty($post['add_group'])) {
         ItemGroupHandler::setChildren($post['add_group'], array($planid));
         unset($post['add_group']);
     }
     if (empty($post['micro_integrations'])) {
         $post['micro_integrations'] = array();
     }
     if (!empty($post['micro_integrations_plan'])) {
         foreach ($post['micro_integrations_plan'] as $miname) {
             // Create new blank MIs
             $mi = new microIntegration();
             $mi->load(0);
             $mi->class_name = $miname;
             if (!$mi->callIntegration(true)) {
                 continue;
             }
             $mi->hidden = 1;
             $mi->storeload();
             // Add in new MI id
             $post['micro_integrations'][] = $mi->id;
         }
         $mi->reorder();
         unset($post['micro_integrations_plan']);
     }
     if (!empty($post['micro_integrations_hidden'])) {
         // Recover hidden MI relation to full list
         $post['micro_integrations'] = array_merge($post['micro_integrations'], $post['micro_integrations_hidden']);
         unset($post['micro_integrations_hidden']);
     }
     if (!empty($post['micro_integrations_inherited'])) {
         unset($post['micro_integrations_inherited']);
     }
     // Update MI settings
     foreach ($post['micro_integrations'] as $miid) {
         $mi = new microIntegration();
         $mi->load($miid);
         // Only act special on hidden MIs
         if (!$mi->hidden) {
             continue;
         }
         $prefix = 'MI_' . $miid . '_';
         // Get Settings from post array
         $settings = array();
         foreach ($post as $name => $value) {
             if (strpos($name, $prefix) === 0) {
                 $rname = str_replace($prefix, '', $name);
                 $settings[$rname] = $value;
                 unset($post[$name]);
             }
         }
         // If we indeed HAVE settings, more to come here
         if (empty($settings)) {
             continue;
         }
         $mi->savePostParams($settings);
         // First, check whether there is already an MI with the exact same settings
         $similarmis = microIntegrationHandler::getMIList(false, false, true, false, $mi->classname);
         $similarmi = false;
         if (!empty($similarmis)) {
             foreach ($similarmis as $miobj) {
                 if ($miobj->id == $mi->id) {
                     continue;
                 }
                 if (microIntegrationHandler::compareMIs($mi, $miobj->id)) {
                     $similarmi = $miobj->id;
                 }
             }
         }
         if ($similarmi) {
             // We have a similar MI - unset old reference
             $ref = array_search($mi->id, $post['micro_integrations']);
             unset($post['micro_integrations'][$ref]);
             // No MI is similar, lets check for other plans
             $plans = microIntegrationHandler::getPlansbyMI($mi->id);
             foreach ($plans as $cid => $pid) {
                 if ($pid == $this->id) {
                     unset($plans[$cid]);
                 }
             }
             if (count($plans) <= 1) {
                 // No other plan depends on this MI, just delete it
                 $mi->delete();
             }
             // Set new MI
             $post['micro_integrations'][] = $similarmi;
         } else {
             // No MI is similar, lets check for other plans
             $plans = microIntegrationHandler::getPlansbyMI($mi->id);
             foreach ($plans as $cid => $pid) {
                 if ($pid == $this->id) {
                     unset($plans[$cid]);
                 }
             }
             if (count($plans) > 1) {
                 // We have other plans depending on THIS setup of the MI, unset original reference
                 $ref = array_search($mi->id, $post['micro_integrations']);
                 unset($post['micro_integrations'][$ref]);
                 // And create new MI
                 $mi->id = 0;
                 $mi->storeload();
                 // Set new MI
                 $post['micro_integrations'][] = $mi->id;
             } else {
                 $mi->storeload();
             }
         }
     }
     // Filter out fixed variables
     $fixed = array('active', 'visible', 'name', 'desc', 'email_desc', 'micro_integrations');
     foreach ($fixed as $varname) {
         if (isset($post[$varname])) {
             $this->{$varname} = $post[$varname];
             unset($post[$varname]);
         } else {
             $this->{$varname} = '';
         }
     }
     // Get selected processors ( have to be filtered out )
     $processors = array();
     foreach ($post as $key => $value) {
         if ($key == 'processor_selectmode') {
             continue;
         }
         if (strpos($key, 'processor_') === 0 && $value) {
             $ppid = str_replace('processor_', '', $key);
             if (!in_array($ppid, $processors)) {
                 $processors[] = $ppid;
                 unset($post[$key]);
             }
         }
     }
     // Filter out params
     $fixed = array('full_free', 'full_amount', 'full_period', 'full_periodunit', 'trial_free', 'trial_amount', 'trial_period', 'trial_periodunit', 'gid_enabled', 'gid', 'lifetime', 'standard_parent', 'fallback', 'fallback_req_parent', 'similarplans', 'equalplans', 'make_active', 'make_primary', 'update_existing', 'customthanks', 'customtext_thanks_keeporiginal', 'customamountformat', 'customtext_thanks', 'override_activation', 'override_regmail', 'notauth_redirect', 'fixed_redirect', 'hide_duration_checkout', 'addtocart_redirect', 'addtocart_max', 'cart_behavior', 'notes', 'meta', 'processor_selectmode');
     $params = array();
     foreach ($fixed as $varname) {
         if (!isset($post[$varname])) {
             continue;
         }
         $params[$varname] = $post[$varname];
         unset($post[$varname]);
     }
     $params['processors'] = $processors;
     $this->saveParams($params);
     // Filter out restrictions
     $fixed = aecRestrictionHelper::paramList();
     $fixed = array_merge($fixed, array('inventory_amount_enabled', 'inventory_amount', 'inventory_amount_used'));
     $restrictions = array();
     foreach ($fixed as $varname) {
         if (!isset($post[$varname])) {
             continue;
         }
         $restrictions[$varname] = $post[$varname];
         unset($post[$varname]);
     }
     $this->restrictions = $restrictions;
     // There might be deletions set for groups
     foreach ($post as $varname => $content) {
         if (strpos($varname, 'group_delete_') !== false && $content) {
             $parentid = (int) str_replace('group_delete_', '', $varname);
             ItemGroupHandler::removeChildren($planid, array($parentid));
             unset($post[$varname]);
         }
     }
     // The rest of the vars are custom params
     $custom_params = array();
     foreach ($post as $varname => $content) {
         if (substr($varname, 0, 4) != 'mce_') {
             $custom_params[$varname] = $content;
         }
         unset($post[$varname]);
     }
     $this->custom_params = $custom_params;
 }