public function checkPrettyUrlAction()
{
$docId = $this->getParam("id");
$path = trim($this->getParam("path"));
$path = rtrim($path, "/");
$success = true;
// must start with /
if (strpos($path, "/") !== 0) {
$success = false;
}
if (strlen($path) < 2) {
$success = false;
}
if (!Tool::isValidPath($path)) {
$success = false;
}
$list = new Document\Listing();
$list->setCondition("(CONCAT(path, `key`) = ? OR id IN (SELECT id from documents_page WHERE prettyUrl = ?))\n AND id != ?", [$path, $path, $docId]);
if ($list->getTotalCount() > 0) {
$success = false;
}
$this->_helper->json(["success" => $success]);
}