|
@@ -87,13 +87,17 @@ class PackageController extends Controller
|
|
*/
|
|
*/
|
|
public function submitPackageAction(Request $req)
|
|
public function submitPackageAction(Request $req)
|
|
{
|
|
{
|
|
|
|
+ $user = $this->getUser();
|
|
|
|
+ if (!$user->isEnabled()) {
|
|
|
|
+ throw new AccessDeniedException();
|
|
|
|
+ }
|
|
|
|
+
|
|
$package = new Package;
|
|
$package = new Package;
|
|
$package->setEntityRepository($this->getDoctrine()->getRepository('PackagistWebBundle:Package'));
|
|
$package->setEntityRepository($this->getDoctrine()->getRepository('PackagistWebBundle:Package'));
|
|
$package->setRouter($this->get('router'));
|
|
$package->setRouter($this->get('router'));
|
|
$form = $this->createForm(PackageType::class, $package, [
|
|
$form = $this->createForm(PackageType::class, $package, [
|
|
'action' => $this->generateUrl('submit'),
|
|
'action' => $this->generateUrl('submit'),
|
|
]);
|
|
]);
|
|
- $user = $this->getUser();
|
|
|
|
$package->addMaintainer($user);
|
|
$package->addMaintainer($user);
|
|
|
|
|
|
$form->handleRequest($req);
|
|
$form->handleRequest($req);
|
|
@@ -310,6 +314,10 @@ class PackageController extends Controller
|
|
return $this->redirect($this->generateUrl('search', array('q' => $name, 'reason' => 'package_not_found')));
|
|
return $this->redirect($this->generateUrl('search', array('q' => $name, 'reason' => 'package_not_found')));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ($package->isAbandoned() && $package->getReplacementPackage() === 'spam/spam') {
|
|
|
|
+ throw new NotFoundHttpException('This is a spam package');
|
|
|
|
+ }
|
|
|
|
+
|
|
if ('json' === $req->getRequestFormat()) {
|
|
if ('json' === $req->getRequestFormat()) {
|
|
$data = $package->toArray($this->getDoctrine()->getRepository('PackagistWebBundle:Version'));
|
|
$data = $package->toArray($this->getDoctrine()->getRepository('PackagistWebBundle:Version'));
|
|
$data['dependents'] = $repo->getDependentCount($package->getName());
|
|
$data['dependents'] = $repo->getDependentCount($package->getName());
|
|
@@ -525,6 +533,10 @@ class PackageController extends Controller
|
|
return new Response(json_encode(array('status' => 'error', 'message' => 'Package not found',)), 404);
|
|
return new Response(json_encode(array('status' => 'error', 'message' => 'Package not found',)), 404);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ($package->isAbandoned() && $package->getReplacementPackage() === 'spam/spam') {
|
|
|
|
+ throw new NotFoundHttpException('This is a spam package');
|
|
|
|
+ }
|
|
|
|
+
|
|
$username = $req->request->has('username') ?
|
|
$username = $req->request->has('username') ?
|
|
$req->request->get('username') :
|
|
$req->request->get('username') :
|
|
$req->query->get('username');
|
|
$req->query->get('username');
|