static function getRestrictionsArray($restrictions)
 {
     $newrest = array();
     // Check for a fixed GID - this certainly overrides the others
     if (!empty($restrictions['fixgid_enabled'])) {
         $newrest['fixgid'] = (int) $restrictions['fixgid'];
     } else {
         // No fixed GID, check for min GID
         if (!empty($restrictions['mingid_enabled'])) {
             $newrest['mingid'] = (int) $restrictions['mingid'];
         }
         // Check for max GID
         if (!empty($restrictions['maxgid_enabled'])) {
             $newrest['maxgid'] = (int) $restrictions['maxgid'];
         }
     }
     // First we sort out the group restrictions and convert them into plan restrictions
     // Check for a directly previously used group
     if (!empty($restrictions['previousgroup_req_enabled'])) {
         if (!empty($restrictions['previousgroup_req'])) {
             $restrictions = aecRestrictionHelper::addGroupPlans($restrictions, 'previousgroup_req', 'previousplan_req');
             $restrictions['previousplan_req_enabled'] = true;
         }
     }
     // Check for a directly previously used group
     if (!empty($restrictions['previousgroup_req_enabled_excluded'])) {
         if (!empty($restrictions['previousgroup_req_excluded'])) {
             $restrictions = aecRestrictionHelper::addGroupPlans($restrictions, 'previousgroup_req_excluded', 'previousplan_req_excluded');
             $restrictions['previousplan_req_enabled_excluded'] = true;
         }
     }
     // Check for a currently used group
     if (!empty($restrictions['currentgroup_req_enabled'])) {
         if (!empty($restrictions['currentgroup_req'])) {
             $restrictions = aecRestrictionHelper::addGroupPlans($restrictions, 'currentgroup_req', 'currentplan_req');
             $restrictions['currentplan_req_enabled'] = true;
         }
     }
     // Check for a currently used group
     if (!empty($restrictions['currentgroup_req_enabled_excluded'])) {
         if (!empty($restrictions['currentgroup_req_excluded'])) {
             $restrictions = aecRestrictionHelper::addGroupPlans($restrictions, 'currentgroup_req_excluded', 'currentplan_req_excluded');
             $restrictions['currentplan_req_enabled_excluded'] = true;
         }
     }
     // Check for a overall used group
     if (!empty($restrictions['overallgroup_req_enabled'])) {
         if (!empty($restrictions['overallgroup_req'])) {
             $restrictions = aecRestrictionHelper::addGroupPlans($restrictions, 'overallgroup_req', 'overallplan_req');
             $restrictions['overallplan_req_enabled'] = true;
         }
     }
     // Check for a overall used group
     if (!empty($restrictions['overallgroup_req_enabled_excluded'])) {
         if (!empty($restrictions['overallgroup_req_excluded'])) {
             $restrictions = aecRestrictionHelper::addGroupPlans($restrictions, 'overallgroup_req_excluded', 'overallplan_req_excluded');
             $restrictions['overallplan_req_enabled_excluded'] = true;
         }
     }
     // And now we prepare the individual plan restrictions
     // Check for a directly previously used plan
     if (!empty($restrictions['previousplan_req_enabled'])) {
         if (!empty($restrictions['previousplan_req'])) {
             $newrest['plan_previous'] = $restrictions['previousplan_req'];
         }
     }
     // Check for a directly previously used plan
     if (!empty($restrictions['previousplan_req_enabled_excluded'])) {
         if (!empty($restrictions['previousplan_req_excluded'])) {
             $newrest['plan_previous_excluded'] = $restrictions['previousplan_req_excluded'];
         }
     }
     // Check for a currently used plan
     if (!empty($restrictions['currentplan_req_enabled'])) {
         if (!empty($restrictions['currentplan_req'])) {
             $newrest['plan_present'] = $restrictions['currentplan_req'];
         }
     }
     // Check for a currently used plan
     if (!empty($restrictions['currentplan_req_enabled_excluded'])) {
         if (!empty($restrictions['currentplan_req_excluded'])) {
             $newrest['plan_present_excluded'] = $restrictions['currentplan_req_excluded'];
         }
     }
     // Check for a overall used plan
     if (!empty($restrictions['overallplan_req_enabled'])) {
         if (!empty($restrictions['overallplan_req'])) {
             $newrest['plan_overall'] = $restrictions['overallplan_req'];
         }
     }
     // Check for a overall used plan
     if (!empty($restrictions['overallplan_req_enabled_excluded'])) {
         if (!empty($restrictions['overallplan_req_excluded'])) {
             $newrest['plan_overall_excluded'] = $restrictions['overallplan_req_excluded'];
         }
     }
     if (!empty($restrictions['used_plan_min_enabled'])) {
         if (!empty($restrictions['used_plan_min_amount']) && isset($restrictions['used_plan_min'])) {
             if (!isset($newrest['plan_amount_min'])) {
                 $newrest['plan_amount_min'] = array();
             }
             if (is_array($restrictions['used_plan_min'])) {
                 foreach ($restrictions['used_plan_min'] as $planid) {
                     if ($planid) {
                         $newrest['plan_amount_min'][] = (int) $planid . ',' . (int) $restrictions['used_plan_min_amount'];
                     }
                 }
             } else {
                 $newrest['plan_amount_min'][] = array((int) $restrictions['used_plan_min'] . ',' . (int) $restrictions['used_plan_min_amount']);
             }
         }
     }
     // Check for a overall used group with amount minimum
     if (!empty($restrictions['used_group_min_enabled'])) {
         if (!empty($restrictions['used_group_min_amount']) && isset($restrictions['used_group_min'])) {
             $temp = aecRestrictionHelper::addGroupPlans($restrictions, 'used_group_min', 'used_plan_min', array());
             $ps = array();
             foreach ($temp['used_plan_min'] as $planid) {
                 if ($planid) {
                     $newrest['plan_amount_min'][] = (int) $planid . ',' . (int) $restrictions['used_group_min_amount'];
                 }
             }
         }
     }
     // Check for a overall used plan with amount maximum
     if (!empty($restrictions['used_plan_max_enabled'])) {
         if (!empty($restrictions['used_plan_max_amount']) && isset($restrictions['used_plan_max'])) {
             if (!isset($newrest['plan_amount_max'])) {
                 $newrest['plan_amount_max'] = array();
             }
             if (is_array($restrictions['used_plan_max'])) {
                 foreach ($restrictions['used_plan_max'] as $planid) {
                     if ($planid) {
                         $newrest['plan_amount_max'][] = (int) $planid . ',' . (int) $restrictions['used_plan_max_amount'];
                     }
                 }
             } else {
                 $newrest['plan_amount_max'][] = (int) $restrictions['used_plan_max'] . ',' . (int) $restrictions['used_plan_max_amount'];
             }
         }
     }
     // Check for a overall used group with amount maximum
     if (!empty($restrictions['used_group_max_enabled'])) {
         if (!empty($restrictions['used_group_max_amount']) && isset($restrictions['used_group_max'])) {
             $temp = aecRestrictionHelper::addGroupPlans($restrictions, 'used_group_max', 'used_plan_max', array());
             $ps = array();
             foreach ($temp['used_plan_max'] as $planid) {
                 if ($planid) {
                     $newrest['plan_amount_max'][] = (int) $planid . ',' . (int) $restrictions['used_group_max_amount'];
                 }
             }
         }
     }
     // Check for custom restrictions
     if (!empty($restrictions['custom_restrictions_enabled'])) {
         if (!empty($restrictions['custom_restrictions'])) {
             $newrest['custom_restrictions'] = aecRestrictionHelper::transformCustomRestrictions($restrictions['custom_restrictions']);
         }
     }
     return $newrest;
 }