FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AdminContentDelete.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2015-2017 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
12 use Symfony\Component\HttpFoundation\Request;
13 use Symfony\Component\HttpFoundation\Response;
14 
16 {
17  const NAME = 'content_unlink';
18 
20  private $folderDao;
21 
22  function __construct()
23  {
24  parent::__construct(self::NAME, array(
25  self::TITLE => _("Unlink upload or folder"),
26  self::MENU_LIST => "Organize::Folders::Unlink Content",
27  self::PERMISSION => Auth::PERM_ADMIN,
28  self::REQUIRES_LOGIN => TRUE
29  ));
30  $this->folderDao = $GLOBALS['container']->get('dao.folder');
31  }
32 
37  protected function handle(Request $request)
38  {
39  $userId = Auth::getUserId();
40  $vars = array();
41 
42  $folderContentId = intval($request->get('foldercontent'));
43  if ($folderContentId) {
44  try {
45  $this->folderDao->removeContent($folderContentId);
46  } catch (Exception $ex) {
47  $vars['message'] = $ex->getMessage();
48  }
49  }
50 
51  $rootFolderId = $this->folderDao->getRootFolder($userId)->getId();
52  /* @var $uiFolderNav FolderNav */
53  $uiFolderNav = $GLOBALS['container']->get('ui.folder.nav');
54  $vars['folderTree'] = $uiFolderNav->showFolderTree($rootFolderId);
55 
56  return $this->render('admin_content_delete.html.twig', $this->mergeWithDefault($vars));
57  }
58 }
59 
60 register_plugin(new AdminContentDelete());
handle(Request $request)
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24
render($templateName, $vars=null, $headers=null)
#define PERM_ADMIN
Administrator.
Definition: libfossology.h:34