Exemplo n.º 1
0
    unset($_REQUEST['quota_id']);
}
$gQuota = new LibertyQuota(!empty($_REQUEST['quota_id']) ? $_REQUEST['quota_id'] : NULL);
if (!empty($_REQUEST['savequota'])) {
    if ($gQuota->store($_REQUEST)) {
        header('Location: ' . KERNEL_PKG_URL . 'admin/index.php?page=quota');
        die;
    } else {
        $saveError = TRUE;
        $gBitSmarty->assignByRef('errors', $gQuota->mErrors);
    }
} elseif (!empty($_REQUEST['assignquota'])) {
    foreach (array_keys($_REQUEST) as $key) {
        if (preg_match('/^quota_group_([-0-9]*)/', $key, $match)) {
            $groupId = $match[1];
            $gQuota->assignQuotaToGroup($_REQUEST[$key], $groupId);
            //vd( $match );
        }
    }
}
$gQuota->load();
if ($gQuota->isValid() || isset($_REQUEST['newquota']) || !empty($saveError)) {
    $gBitSmarty->assignByRef('gQuota', $gQuota);
} else {
    $quotas = $gQuota->getList();
    $systemGroups = $gQuota->getQuotaGroups();
    $gBitSmarty->assignByRef('systemGroups', $systemGroups);
    foreach (array_keys($systemGroups) as $groupId) {
        $groupQuota[$groupId] = $gQuota->getQuotaMenu('quota_group_' . $groupId, $systemGroups[$groupId]['quota_id']);
    }
    $gBitSmarty->assignByRef('groupQuota', $groupQuota);