- case "edit": // Change entries
- foreach ($_POST['lvl'] as $id=>$value)
- {
- // Secure ID
- $id = bigintval($id);
-
- // Update entry
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_refdepths SET level='%s', percents='%s' WHERE id=%d LIMIT 1",
- array(bigintval($value), $_POST['perc'][$id], $id), __FILE__, __LINE__);
- }
- $TEXT = REF_DEPTHS_SAVED;
+ case 'ref':
+ switch (getRequestElement('do')) {
+ case 'add':
+ addSql("INSERT INTO `{?_MYSQL_PREFIX?}_refdepths` (`level`,`percents`) VALUES ('".bigintval(postRequestElement('level'))."','".bigintval(postRequestElement('percents'))."')");
+ break;
+
+ case 'edit': // Change entries
+ foreach (postRequestElement('level') as $id => $value) {
+ // Secure id
+ $id = bigintval($id);
+
+ // Revert german commata
+ setPostRequestElement('percents', array($id => convertCommaToDot(postRequestElement('percents', $id))));
+
+ // Update entry
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refdepths` SET `level`=%s,`percents`=%s WHERE `id`=%s LIMIT 1",
+ array(bigintval($value), convertCommaToDot(postRequestElement('percents', $id)), $id), __FILE__, __LINE__);
+ } // END - foreach
+ $message = '{--ADMIN_REFERRAL_DEPTHS_SAVED--}';
+ break;
+
+ case 'delete':
+ foreach (postRequestElement('id') as $id => $value) {
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `id`=%s LIMIT 1",
+ array(bigintval($id)), __FILE__, __LINE__);
+ } // END - foreach
+ $message = '{--ADMIN_REFERRAL_DEPTHS_DELETED--}';
+ break;
+ } // END - switch
+
+ // Update cache file
+ // @TODO Rewrite this to a filter
+ if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
+ if ($GLOBALS['cache_instance']->loadCacheFile('refdepths')) $GLOBALS['cache_instance']->removeCacheFile();
+ } // END - if