/**
  * \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;
 }
Beispiel #2
0
 /**
  * @param array $row fetched row
  * @param Request $request
  * @param $uri
  * @param $menuPfile
  * @param $menuPfileNoCompare
  * @param array $statusTypesAvailable
  * @param array $users
  * @param string (unique)
  * @return array
  */
 private function showRow($row, Request $request, $uri, $menuPfile, $menuPfileNoCompare, $statusTypesAvailable, $users, $rowCounter)
 {
     $show = $request->get('show');
     $folder = $request->get('folder');
     $uploadId = intval($row['upload_pk']);
     $description = htmlentities($row['upload_desc']);
     $fileName = $row['ufile_name'];
     if (empty($fileName)) {
         $fileName = $row['upload_filename'];
     }
     $itemId = Isartifact($row['ufile_mode']) ? DirGetNonArtifact($row['uploadtree_pk']) : $row['uploadtree_pk'];
     $nameColumn = "<b>{$fileName}</b>";
     if (IsContainer($row['ufile_mode'])) {
         $nameColumn = "<a href='{$uri}&upload={$uploadId}&folder={$folder}&item={$itemId}&show={$show}'>{$nameColumn}</a>";
     }
     $nameColumn .= "<br>";
     if (!empty($description)) {
         $nameColumn .= "<i>{$description}</i><br>";
     }
     $Parm = "upload={$uploadId}&show={$show}&item=" . $row['uploadtree_pk'];
     if (Iscontainer($row['ufile_mode'])) {
         $nameColumn .= MenuRenderer::menuToActiveSelect($menuPfile, $Parm, $uploadId);
     } else {
         $nameColumn .= MenuRenderer::menuToActiveSelect($menuPfileNoCompare, $Parm, $uploadId);
     }
     $modsUploadMulti = MenuHook::getAgentPluginNames('UploadMulti');
     if (!empty($modsUploadMulti)) {
         $nameColumn = '<input type="checkbox" name="uploads[]" class="browse-upload-checkbox" value="' . $uploadId . '"/>' . $nameColumn;
     }
     $dateCol = substr($row['upload_ts'], 0, 19);
     $pairIdPrio = array($uploadId, floatval($row[UploadBrowseProxy::PRIO_COLUMN]));
     if (!$this->userPerm && 4 == $row['status_fk']) {
         $currentStatus = $this->statusTypes[4];
     } else {
         $statusAction = " onchange =\"changeTableEntry(this, {$uploadId},'status_fk' )\" ";
         $currentStatus = $this->createSelect("Status" . $this->userPerm . "Of_{$rowCounter}", $statusTypesAvailable, $row['status_fk'], $statusAction);
     }
     if ($this->userPerm) {
         $action = " onchange =\"changeTableEntry(this, {$uploadId}, 'assignee')\"";
         $currentAssignee = $this->createSelectUsers("AssignedTo_{$rowCounter}", $users, $row['assignee'], $action);
     } else {
         $currentAssignee = array_key_exists($row['assignee'], $users) ? $users[$row['assignee']] : _('Unassigned');
     }
     $rejectableUploadId = $this->userPerm || $row['status_fk'] < 4 ? $uploadId : 0;
     $tripleComment = array($rejectableUploadId, $row['status_fk'], htmlspecialchars($row['status_comment']));
     $sql = "SELECT rf_pk, rf_shortname FROM upload_clearing_license ucl, license_ref" . " WHERE ucl.group_fk=\$1 AND upload_fk=\$2 AND ucl.rf_fk=rf_pk";
     $stmt = __METHOD__ . '.collectMainLicenses';
     $this->dbManager->prepare($stmt, $sql);
     $res = $this->dbManager->execute($stmt, array(Auth::getGroupId(), $uploadId));
     $mainLicenses = array();
     while ($lic = $this->dbManager->fetchArray($res)) {
         $mainLicenses[] = '<a onclick="javascript:window.open(\'' . Traceback_uri() . "?mod=popup-license&rf={$lic['rf_pk']}','License text','width=600,height=400,toolbar=no,scrollbars=yes,resizable=yes');" . '" href="javascript:;">' . $lic['rf_shortname'] . '</a>' . "<img onclick=\"removeMainLicense({$uploadId},{$lic['rf_pk']});\" class=\"delete\" src=\"images/space_16.png\" alt=\"\"/></img>";
     }
     $this->dbManager->freeResult($res);
     $output = array($nameColumn, $currentStatus, $tripleComment, implode(', ', $mainLicenses), $currentAssignee, $dateCol, $pairIdPrio);
     return $output;
 }