do NOT allow to call Api\Etemplate\Widget\Link::ajax_delete() without a positive link_id

This commit is contained in:
ralf 2022-08-04 19:37:12 +02:00 committed by nathan
parent 3e5b6cc570
commit 4d31516929

View File

@ -13,6 +13,7 @@
namespace EGroupware\Api\Etemplate\Widget;
use InvalidArgumentException;
use EGroupware\Api\Etemplate;
use EGroupware\Api;
@ -310,8 +311,19 @@ class Link extends Etemplate\Widget
$response->message(lang('%1 files copied',count($copied)));
}
public static function ajax_delete($value)
/**
* Delete a link specified by its link_id
*
* @param int $value link_id to delete
* @return void
* @throws Api\Json\Exception|InvalidArgumentException
*/
public static function ajax_delete(int $value)
{
if ($value <= 0)
{
throw new InvalidArgumentException();
}
$response = Api\Json\Response::get();
$response->data(Api\Link::unlink($value));
}
@ -430,4 +442,4 @@ class Link extends Etemplate\Widget
//error_log(" " . array2string($valid));
}
}
}
}