Ejemplo n.º 1
0
 /**
  * @param Request $request
  * @return Response
  */
 protected function handle(Request $request)
 {
     $this->folderDao->ensureTopLevelFolder();
     list($folderId, $trustGroupId) = $this->getFolderIdAndTrustGroup($request->get(self::FOLDER_PARAMETER_NAME));
     $ajaxMethodName = $request->get('do');
     if ($ajaxMethodName == "getUploads") {
         $uploadsById = $this->prepareFolderUploads($folderId, $trustGroupId);
         return new JsonResponse($uploadsById, JsonResponse::HTTP_OK);
     }
     return new Response('called without valid method', Response::HTTP_METHOD_NOT_ALLOWED);
 }
Ejemplo n.º 2
0
 public function testGetFolder()
 {
     $this->folderDao->ensureTopLevelFolder();
     $goodFolder = $this->folderDao->getFolder(FolderDao::TOP_LEVEL);
     assertThat($goodFolder, is(anInstanceOf(\Fossology\Lib\Data\Folder\Folder::classname())));
     assertThat($goodFolder->getId(), equalTo(FolderDao::TOP_LEVEL));
     $badFolder = $this->folderDao->getFolder(987);
     assertThat($badFolder, is(nullValue()));
 }
Ejemplo n.º 3
0
 public function check()
 {
     $this->checkDecisionScopes();
     $this->checkUploadStatus();
     $this->checkLicenseEventTypes();
     $this->checkExistsTable('license_candidate');
     $folderDao = new FolderDao($this->dbManager, $GLOBALS['container']->get('dao.user'), $GLOBALS['container']->get('dao.upload'));
     $folderDao->ensureTopLevelFolder();
     return $this->errors;
 }
Ejemplo n.º 4
0
 protected function handle(Request $request)
 {
     // Handle request
     $this->folderDao->ensureTopLevelFolder();
     $message = "";
     $description = "";
     if ($request->isMethod(Request::METHOD_POST)) {
         list($success, $message, $description) = $this->handleUpload($request);
     }
     $vars['message'] = $message;
     $vars['descriptionInputValue'] = $description ?: "";
     $vars['descriptionInputName'] = self::DESCRIPTION_INPUT_NAME;
     $vars['folderParameterName'] = self::FOLDER_PARAMETER_NAME;
     $vars['upload_max_filesize'] = ini_get('upload_max_filesize');
     $vars['agentCheckBoxMake'] = '';
     $rootFolder = $this->folderDao->getRootFolder(Auth::getUserId());
     $folderStructure = $this->folderDao->getFolderStructure($rootFolder->getId());
     $vars['folderStructure'] = $folderStructure;
     $vars['baseUrl'] = $request->getBaseUrl();
     $vars['moduleName'] = $this->getName();
     $vars[self::FOLDER_PARAMETER_NAME] = $request->get(self::FOLDER_PARAMETER_NAME);
     $parmAgentList = MenuHook::getAgentPluginNames("ParmAgents");
     $vars['parmAgentContents'] = array();
     $vars['parmAgentFoots'] = array();
     foreach ($parmAgentList as $parmAgent) {
         $agent = plugin_find($parmAgent);
         $vars['parmAgentContents'][] = $agent->renderContent($vars);
         $vars['parmAgentFoots'][] = $agent->renderFoot($vars);
     }
     $session = $request->getSession();
     $session->set(self::UPLOAD_FORM_BUILD_PARAMETER_NAME, time() . ':' . $_SERVER['REMOTE_ADDR']);
     $vars['uploadFormBuild'] = $session->get(self::UPLOAD_FORM_BUILD_PARAMETER_NAME);
     $vars['uploadFormBuildParameterName'] = self::UPLOAD_FORM_BUILD_PARAMETER_NAME;
     if (@$_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_WRITE) {
         $skip = array("agent_unpack", "agent_adj2nest", "wget_agent");
         $vars['agentCheckBoxMake'] = AgentCheckBoxMake(-1, $skip);
     }
     return $this->handleView($request, $vars);
 }
Ejemplo n.º 5
0
 /**
  * \brief This function returns the output html
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $this->folderDao->ensureTopLevelFolder();
     $folder_pk = GetParm("folder", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     // upload_pk to browse
     $Item = GetParm("item", PARM_INTEGER);
     // uploadtree_pk to browse
     /* check permission if $Upload is given */
     if (!empty($Upload) && !$this->uploadDao->isAccessible($Upload, Auth::getGroupId())) {
         $this->vars['message'] = _("Permission Denied");
         return $this->render('include/base.html.twig');
     }
     if (empty($folder_pk)) {
         try {
             $folder_pk = $this->getFolderId($Upload);
         } catch (Exception $exc) {
             return $exc->getMessage();
         }
     }
     $output = $this->outputItemHtml($Item, $folder_pk, $Upload);
     if ($output instanceof Response) {
         return $output;
     }
     $this->vars['content'] = $output;
     $modsUploadMulti = MenuHook::getAgentPluginNames('UploadMulti');
     if (!empty($modsUploadMulti)) {
         $multiUploadAgents = array();
         foreach ($modsUploadMulti as $mod) {
             $multiUploadAgents[$mod] = $GLOBALS['Plugins'][$mod]->title;
         }
         $this->vars['multiUploadAgents'] = $multiUploadAgents;
     }
     $this->vars['folderId'] = $folder_pk;
     return $this->render('ui-browse.html.twig');
 }