Example #1
0
 /**
  * \brief Given a Folder_pk, list every upload in the folder.
  */
 function ShowFolder($Folder, $Show)
 {
     global $Plugins;
     global $PG_CONN;
     $V = "";
     /* Get list of uploads in this folder */
     $sql = "SELECT * FROM upload\n        INNER JOIN uploadtree ON upload_fk = upload_pk\n        AND upload.pfile_fk = uploadtree.pfile_fk\n        AND parent IS NULL\n        AND lft IS NOT NULL \n        WHERE upload_pk IN\n        (SELECT child_id FROM foldercontents WHERE foldercontents_mode & 2 != 0 AND parent_fk = {$Folder})\n        ORDER BY upload_filename,upload_desc,upload_pk,upload_origin;";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $Uri = Traceback_uri() . "?mod=" . $this->Name;
     $V .= "<table border=1 width='100%'>";
     $V .= "<tr><td valign='top' width='20%'>\n";
     $V .= FolderListScript();
     $text = _("Folder Navigation");
     $V .= "<center><H3>{$text}</H3></center>\n";
     $V .= "<center><small>";
     if ($Folder != GetUserRootFolder()) {
         $text = _("Top");
         $V .= "<a href='" . Traceback_uri() . "?mod=" . $this->Name . "'>{$text}</a> |";
     }
     $text = _("Expand");
     $V .= "<a href='javascript:Expand();'>{$text}</a> |";
     $text = _("Collapse");
     $V .= "<a href='javascript:Collapse();'>{$text}</a> |";
     $text = _("Refresh");
     $V .= "<a href='" . Traceback() . "'>{$text}</a>";
     $V .= "</small></center>";
     $V .= "<P>\n";
     $V .= "<form>\n";
     $V .= FolderListDiv($Folder, 0, $Folder, 1);
     $V .= "</form>\n";
     $V .= "</td><td valign='top'>\n";
     $text = _("Uploads");
     $V .= "<center><H3>{$text}</H3></center>\n";
     $V .= "<table class='text' id='browsetbl' border=0 width='100%' cellpadding=0>\n";
     $text = _("Upload Name and Description");
     $text1 = _("Upload Date");
     $V .= "<th>{$text}</th><th>{$text1}</th></tr>\n";
     /* Browse-Pfile menu */
     $MenuPfile = menu_find("Browse-Pfile", $MenuDepth);
     /* Browse-Pfile menu without the compare menu item */
     $MenuPfileNoCompare = menu_remove($MenuPfile, "Compare");
     while ($Row = pg_fetch_assoc($result)) {
         if (empty($Row['upload_pk'])) {
             continue;
         }
         $Desc = htmlentities($Row['upload_desc']);
         $UploadPk = $Row['upload_pk'];
         /* check permission on upload */
         $UploadPerm = GetUploadPerm($UploadPk);
         if ($UploadPerm < PERM_READ) {
             continue;
         }
         $Name = $Row['ufile_name'];
         if (empty($Name)) {
             $Name = $Row['upload_filename'];
         }
         /* If UploadtreePk is not an artifact, then use it as the root.
            Else get the first non artifact under it.
            */
         if (Isartifact($Row['ufile_mode'])) {
             $UploadtreePk = DirGetNonArtifact($Row['uploadtree_pk'], $uploadtree_tablename);
         } else {
             $UploadtreePk = $Row['uploadtree_pk'];
         }
         $V .= "<tr><td>";
         if (IsContainer($Row['ufile_mode'])) {
             $V .= "<a href='{$Uri}&upload={$UploadPk}&folder={$Folder}&item={$UploadtreePk}&show={$Show}'>";
             $V .= "<b>" . $Name . "</b>";
             $V .= "</a>";
         } else {
             $V .= "<b>" . $Name . "</b>";
         }
         $V .= "<br>";
         if (!empty($Desc)) {
             $V .= "<i>" . $Desc . "</i><br>";
         }
         $Upload = $Row['upload_pk'];
         $Parm = "upload={$Upload}&show={$Show}&item=" . $Row['uploadtree_pk'];
         if (Iscontainer($Row['ufile_mode'])) {
             $V .= menu_to_1list($MenuPfile, $Parm, " ", " ", 1, $UploadPk);
         } else {
             $V .= menu_to_1list($MenuPfileNoCompare, $Parm, " ", " ", 1, $UploadPk);
         }
         /* Job queue link */
         $text = _("History");
         if (plugin_find_id('showjobs') >= 0) {
             $V .= "<a href='" . Traceback_uri() . "?mod=showjobs&upload={$UploadPk}'>[{$text}]</a>";
             $V .= "</td>\n";
             $V .= "<td align='right'>" . substr($Row['upload_ts'], 0, 19) . "</td>";
         }
         $V .= "<tr><td colspan=2>&nbsp;</td></tr>\n";
     }
     pg_free_result($result);
     $V .= "</table>\n";
     $V .= "</td></tr>\n";
     $V .= "</table>\n";
     return $V;
 }
Example #2
0
 /**
  * \brief Given a upload_pk, list every item in it.
  * If it is an individual file, then list the file contents.
  */
 function ShowItem($Upload, $Item, $Show, $Folder, $uploadtree_tablename)
 {
     global $container;
     /** @var DbManager */
     $dbManager = $container->get('db.manager');
     $RowStyle1 = "style='background-color:#ecfaff'";
     // pale blue
     $RowStyle2 = "style='background-color:#ffffe3'";
     // pale yellow
     $ColorSpanRows = 3;
     // Alternate background color every $ColorSpanRows
     $RowNum = 0;
     $V = "";
     /* Use plugin "view" and "download" if they exist. */
     $Uri = Traceback_uri() . "?mod=" . $this->Name . "&folder={$Folder}";
     /* there are three types of Browse-Pfile menus */
     /* menu as defined by their plugins */
     $MenuPfile = menu_find("Browse-Pfile", $MenuDepth);
     /* menu but without Compare */
     $MenuPfileNoCompare = menu_remove($MenuPfile, "Compare");
     /* menu with only Tag and Compare */
     $MenuTag = array();
     foreach ($MenuPfile as $value) {
         if ($value->Name == 'Tag' or $value->Name == 'Compare') {
             $MenuTag[] = $value;
         }
     }
     $Results = GetNonArtifactChildren($Item, $uploadtree_tablename);
     $ShowSomething = 0;
     $V .= "<table class='text' style='border-collapse: collapse' border=0 padding=0>\n";
     $stmtGetFirstChild = __METHOD__ . '.getFirstChild';
     $dbManager->prepare($stmtGetFirstChild, "SELECT uploadtree_pk FROM {$uploadtree_tablename} WHERE parent=\$1 limit 1");
     foreach ($Results as $Row) {
         if (empty($Row['uploadtree_pk'])) {
             continue;
         }
         $ShowSomething = 1;
         $Name = $Row['ufile_name'];
         /* Set alternating row background color - repeats every $ColorSpanRows rows */
         $RowStyle = $RowNum++ % (2 * $ColorSpanRows) < $ColorSpanRows ? $RowStyle1 : $RowStyle2;
         $V .= "<tr {$RowStyle}>";
         /* Check for children so we know if the file should by hyperlinked */
         $result = $dbManager->execute($stmtGetFirstChild, array($Row['uploadtree_pk']));
         $HasChildren = $dbManager->fetchArray($result);
         $dbManager->freeResult($result);
         $Parm = "upload={$Upload}&show={$Show}&item=" . $Row['uploadtree_pk'];
         $Link = $HasChildren ? "{$Uri}&show={$Show}&upload={$Upload}&item={$Row['uploadtree_pk']}" : NULL;
         if ($Show == 'detail') {
             $V .= "<td class='mono'>" . DirMode2String($Row['ufile_mode']) . "</td>";
             if (!Isdir($Row['ufile_mode'])) {
                 $V .= "<td align='right'>&nbsp;&nbsp;" . number_format($Row['pfile_size'], 0, "", ",") . "&nbsp;&nbsp;</td>";
             } else {
                 $V .= "<td>&nbsp;</td>";
             }
         }
         $displayItem = Isdir($Row['ufile_mode']) ? "{$Name}/" : $Name;
         if (!empty($Link)) {
             $displayItem = "<a href=\"{$Link}\">{$displayItem}</a>";
         }
         if (Iscontainer($Row['ufile_mode'])) {
             $displayItem = "<b>{$displayItem}</b>";
         }
         $V .= "<td>{$displayItem}</td>\n";
         if (!Iscontainer($Row['ufile_mode'])) {
             $V .= menu_to_1list($MenuPfileNoCompare, $Parm, "<td>", "</td>\n", 1, $Upload);
         } else {
             if (!Isdir($Row['ufile_mode'])) {
                 $V .= menu_to_1list($MenuPfile, $Parm, "<td>", "</td>\n", 1, $Upload);
             } else {
                 $V .= menu_to_1list($MenuTag, $Parm, "<td>", "</td>\n", 1, $Upload);
             }
         }
     }
     /* foreach($Results as $Row) */
     $V .= "</table>\n";
     if (!$ShowSomething) {
         $text = _("No files");
         $V .= "<b>{$text}</b>\n";
     } else {
         $V .= "<hr>\n";
         if (count($Results) == 1) {
             $text = _("1 item");
             $V .= "{$text}\n";
         } else {
             $text = _("items");
             $V .= count($Results) . " {$text}\n";
         }
     }
     return $V;
 }
Example #3
0
 /**
  * @param Request $request
  * @return JsonResponse
  */
 protected function respondFolderGetTableData(Request $request)
 {
     /* Get list of uploads in this folder */
     list($result, $iTotalDisplayRecords, $iTotalRecords) = $this->getListOfUploadsOfFolder($request);
     $uri = Traceback_uri() . "?mod=license";
     /* Browse-Pfile menu */
     $menuPfile = menu_find("Browse-Pfile", $menuDepth);
     /* Browse-Pfile menu without the compare menu item */
     $menuPfileNoCompare = menu_remove($menuPfile, "Compare");
     $users = $this->userDao->getUserChoices();
     $statusTypesAvailable = $this->uploadDao->getStatusTypeMap();
     if (!$this->userPerm) {
         unset($statusTypesAvailable[4]);
     }
     $output = array();
     $rowCounter = 0;
     while ($row = $this->dbManager->fetchArray($result)) {
         if (empty($row['upload_pk']) || !$this->uploadDao->isAccessible($row['upload_pk'], Auth::getGroupId())) {
             continue;
         }
         $rowCounter++;
         $output[] = $this->showRow($row, $request, $uri, $menuPfile, $menuPfileNoCompare, $statusTypesAvailable, $users, $rowCounter);
     }
     $this->dbManager->freeResult($result);
     return new JsonResponse(array('sEcho' => intval($request->get('sEcho')), 'aaData' => $output, 'iTotalRecords' => $iTotalRecords, 'iTotalDisplayRecords' => $iTotalDisplayRecords));
 }