Project import generated by Copybara.
GitOrigin-RevId: 63746295f1a5ab5a619056791995793d65529e62
diff --git a/src/doaddcategory.php b/src/doaddcategory.php
new file mode 100644
index 0000000..2f706d3
--- /dev/null
+++ b/src/doaddcategory.php
@@ -0,0 +1,21 @@
+<?php
+require_once("core.php");
+security::checkType(security::ADMIN);
+
+if (!security::checkParams("POST", [
+ ["name", security::PARAM_NEMPTY],
+ ["emails", security::PARAM_ISSET],
+ ["parent", security::PARAM_ISSET]
+])) {
+ security::go("categories.php?msg=empty");
+}
+
+$name = $_POST["name"];
+$emails = $_POST["emails"];
+$parent = (int)$_POST["parent"];
+
+if (categories::add($name, $emails, $parent)) {
+ security::go("categories.php?msg=added");
+} else {
+ security::go("categories.php?msg=unexpected");
+}