20 use Symfony\Component\HttpFoundation\JsonResponse;
 
   21 use Symfony\Component\HttpFoundation\Request;
 
   22 use Symfony\Component\HttpFoundation\Response;
 
   26   const NAME = 
"browse-processPost";
 
   35   private $dataTablesUtility;
 
   37   private $filterParams;
 
   43   function __construct()
 
   45     parent::__construct(self::NAME, array(
 
   46       self::REQUIRES_LOGIN => 
false,
 
   50     $this->uploadDao = $container->get(
'dao.upload');
 
   51     $this->userDao = $container->get(
'dao.user');
 
   52     $this->
dbManager = $container->get(
'db.manager');
 
   53     $this->dataTablesUtility = $container->get(
'utils.data_tables_utility');
 
   59   protected function handle(Request $request)
 
   62     $gup = $this->
dbManager->getSingleRow(
'SELECT group_perm FROM group_user_member WHERE user_fk=$1 AND group_fk=$2',
 
   65       throw new \Exception(
'You are assigned to wrong group.');
 
   67     $this->userPerm = $gup[
'group_perm'];
 
   69     $uploadId = intval($request->get(
'uploadId'));
 
   70     if ($uploadId && !$this->uploadDao->isAccessible($uploadId, $groupId)) {
 
   71       throw new \Exception(
'You cannot access to this upload');
 
   74     $columnName = $request->get(
'columnName');
 
   75     $statusId = intval($request->get(
'statusId'));
 
   76     $value = intval($request->get(
'value'));
 
   77     $moveUpload = intval($request->get(
"move"));
 
   78     $beyondUpload = intval($request->get(
"beyond"));
 
   79     $commentText = $request->get(
'commentText');
 
   80     $direction = $request->get(
'direction');
 
   82     if (! empty($columnName) && ! empty($uploadId) && ! empty($value)) {
 
   84       $uploadBrowseProxy->updateTable($columnName, $uploadId, $value);
 
   85     } 
else if (! empty($moveUpload) && ! empty($beyondUpload)) {
 
   87       $uploadBrowseProxy->moveUploadBeyond($moveUpload, $beyondUpload);
 
   88     } 
else if (! empty($uploadId) && ! empty($direction)) {
 
   90       $uploadBrowseProxy->moveUploadToInfinity($uploadId, $direction == 
'top');
 
   91     } 
else if (!empty($uploadId) && !empty($commentText) && !empty($statusId)) {
 
   93       $uploadBrowseProxy->setStatusAndComment($uploadId, $statusId, $commentText);
 
   97     return new Response(
'');
 
  112     $menuPfile = 
menu_find(
"Browse-Pfile", $menuDepth);
 
  114     $menuPfileNoCompare = 
menu_remove($menuPfile, 
"Compare");
 
  116     $users = $this->userDao->getUserChoices();
 
  118     $statusTypesAvailable = $this->uploadDao->getStatusTypeMap();
 
  119     if (!$this->userPerm) {
 
  120       unset($statusTypesAvailable[4]);
 
  125     while ($row = $this->
dbManager->fetchArray($result)) {
 
  126       if (empty($row[
'upload_pk']) || !$this->uploadDao->isAccessible($row[
'upload_pk'],
Auth::getGroupId())) {
 
  130       $output[] = $this->
showRow($row, $request, $uri, $menuPfile, $menuPfileNoCompare, $statusTypesAvailable, $users, $rowCounter);
 
  133     return new JsonResponse(array(
 
  134               'sEcho' => intval($request->get(
'sEcho')),
 
  136               'iTotalRecords' => $iTotalRecords,
 
  137               'iTotalDisplayRecords' => $iTotalDisplayRecords
 
  153   private function showRow($row,Request $request, $uri, $menuPfile, $menuPfileNoCompare, $statusTypesAvailable, $users, $rowCounter)
 
  155     $show = $request->get(
'show');
 
  156     $folder = $request->get(
'folder');
 
  158     $uploadId = intval($row[
'upload_pk']);
 
  159     $description = htmlentities($row[
'upload_desc']);
 
  161     $fileName = $row[
'ufile_name'];
 
  162     if (empty($fileName)) {
 
  163       $fileName = $row[
'upload_filename'];
 
  167     if (strlen($fileName) > 20) {
 
  168       $splitFileName = str_split($fileName, 20);
 
  170       foreach ($splitFileName as $key => $value) {
 
  171         if (strlen($value) > 3 && $key > 0) {
 
  172           $fileName .= 
"<br/>".$value;
 
  178     $nameColumn = 
"<strong class='btn btn-sm font-weight-bold' style='margin-left:10px;font-size:11pt;'>$fileName</strong>";
 
  179     if (IsContainer($row[
'ufile_mode'])) {
 
  180       $nameColumn = 
"<a href='$uri&upload=$uploadId&folder=$folder&item=$itemId&show=$show'>$nameColumn</a>";
 
  182     $nameColumn .= 
"<br>";
 
  183     if (!empty($description)) {
 
  184       $nameColumn .= 
"<i>$description</i><br>";
 
  186     $Parm = 
"upload=$uploadId&show=$show&item=" . $row[
'uploadtree_pk'];
 
  194     if (!empty($modsUploadMulti)) {
 
  195       $nameColumn = 
'<input type="checkbox" name="uploads[]" class="browse-upload-checkbox" style="width:1.10rem;height:1.10rem;" value="'.$uploadId.
'"/>'.$nameColumn;
 
  199     if (!$this->userPerm && 4 == $row[
'status_fk']) {
 
  200       $currentStatus = $this->statusTypes[4];
 
  202       $statusAction = 
" onchange =\"changeTableEntry(this, $uploadId,'status_fk' )\" ";
 
  203       $currentStatus = $this->createSelect(
"Status" . $this->userPerm . 
"Of_$rowCounter", $statusTypesAvailable, $row[
'status_fk'], $statusAction);
 
  205     if ($this->userPerm) {
 
  206       $action = 
" onchange =\"changeTableEntry(this, $uploadId, 'assignee')\"";
 
  207       $currentAssignee = $this->
createSelectUsers(
"AssignedTo_$rowCounter", $users, $row[
'assignee'], $action );
 
  209       $currentAssignee = array_key_exists($row[
'assignee'], $users) ? $users[$row[
'assignee']] : _(
'Unassigned');
 
  211     $rejectableUploadId = ($this->userPerm || $row[
'status_fk'] < 4) ? $uploadId : 0;
 
  212     $tripleComment = array($rejectableUploadId, $row[
'status_fk'], htmlspecialchars($row[
'status_comment']));
 
  214     $sql = 
"SELECT rf_pk, rf_shortname FROM license_ref lf JOIN upload_clearing_license ucl" 
  215             . 
" ON lf.rf_pk=ucl.rf_fk WHERE upload_fk=$1 AND ucl.group_fk=$2";
 
  216     $stmt = __METHOD__.
'.collectMainLicenses';
 
  218     $lic = $this->
dbManager->getRows($sql, $mainParams, $stmt);
 
  219     $mainLicenses = array();
 
  220     foreach ($lic as $mainLic) {
 
  221       $mainLicenses[] = 
'<a onclick="javascript:window.open(\''.Traceback_uri()
 
  222               .
"?mod=popup-license&rf=$mainLic[rf_pk]','License text','width=600,height=400,toolbar=no,scrollbars=yes,resizable=yes');" 
  223               .
'" href="javascript:;">'.$mainLic[
'rf_shortname'].
'</a>' 
  224               .
"<img onclick=\"removeMainLicense($uploadId,$mainLic[rf_pk]);\" class=\"delete\" src=\"images/space_16.png\" alt=\"\"/></img>";
 
  227     return array($nameColumn, $nameAction, $currentStatus, $tripleComment, implode(
', ', $mainLicenses), $dateCol, $currentAssignee);
 
  236   private function createSelectUsers($selectElementName, $databaseMap, $selectedValue, $action = 
"")
 
  238     if (array_key_exists($_SESSION[
'UserId'], $databaseMap)) {
 
  239       $databaseMap[$_SESSION[
'UserId']] = _(
'-- Me --');
 
  241     $databaseMap[1] = _(
'Unassigned');
 
  242     return $this->createSelect($selectElementName,$databaseMap, $selectedValue,$action);
 
  246   private function createSelect($id,$options,$select=
'',$action=
'')
 
  248     $html = 
"<select class='form-control-sm' style=\"max-width:250px;\" name=\"$id\" id=\"$id\" $action class=\"ui-render-select2\">";
 
  249     foreach ($options as $key=>$disp) {
 
  250       $html .= 
'<option value="'.$key.
'"';
 
  251       if ($key == $select) {
 
  252         $html .= 
' selected';
 
  254       $html .= 
">$disp</option>";
 
  256     $html .= 
'</select>';
 
  268     $params = array($request->get(
'folder'));
 
  269     $partQuery = $uploadBrowseProxy->getFolderPartialQuery($params);
 
  271     $iTotalRecordsRow = $this->
dbManager->getSingleRow(
"SELECT count(*) FROM $partQuery", $params, __METHOD__ . 
"count.all");
 
  272     $iTotalRecords = $iTotalRecordsRow[
'count'];
 
  274     $this->filterParams = $params;
 
  275     $filter = $this->getSearchString($request->get(
'sSearch'));
 
  276     $filter .= $this->
getIntegerFilter(intval($request->get(
'assigneeSelected')), 
'assignee');
 
  277     $filter .= $this->
getIntegerFilter(intval($request->get(
'statusSelected')), 
'status_fk');
 
  279     $iTotalDisplayRecordsRow = $this->
dbManager->getSingleRow(
"SELECT count(*) FROM $partQuery $filter",
 
  280         $this->filterParams, __METHOD__ . 
".count.". $filter);
 
  281     $iTotalDisplayRecords = $iTotalDisplayRecordsRow[
'count'];
 
  283     $orderString = $this->getOrderString();
 
  284     $stmt = __METHOD__ . 
"getFolderContents" . $orderString . $filter;
 
  286     $statementString = 
"SELECT upload.*,upload_clearing.*,uploadtree.ufile_name,uploadtree.ufile_mode,uploadtree.uploadtree_pk" 
  287             . 
" FROM $partQuery $filter $orderString";
 
  288     $rangedFilterParams = $this->filterParams;
 
  289     $rangedFilterParams[] = intval($request->get(
'iDisplayStart'));
 
  290     $statementString .= 
' OFFSET $' . count($rangedFilterParams);
 
  291     $rangedFilterParams[] = intval($request->get(
'iDisplayLength'));
 
  292     $statementString .= 
' LIMIT $' . count($rangedFilterParams);
 
  294     $this->
dbManager->prepare($stmt, $statementString);
 
  295     $result = $this->
dbManager->execute($stmt, $rangedFilterParams);
 
  297     return array($result, $iTotalDisplayRecords, $iTotalRecords);
 
  300   private function getOrderString()
 
  302     $columnNamesInDatabase = array(
'upload_filename', 
'upload_clearing.status_fk', 
'UNUSED', 
'UNUSED', 
'upload_clearing.assignee', 
'upload_ts', 
'upload_clearing.priority');
 
  304     return $this->dataTablesUtility->getSortingString($_GET, $columnNamesInDatabase);
 
  307   private function getSearchString($searchPattern)
 
  309     if (empty($searchPattern)) {
 
  312     $this->filterParams[] = 
"%$searchPattern%";
 
  313     return ' AND upload_filename ilike $' . count($this->filterParams) . 
' ';
 
  325     $this->filterParams[] = $var;
 
  326     return " AND $columnName=$" . count($this->filterParams) . 
' ';
 
  330 register_plugin(
new AjaxBrowse());
 
Contains the constants and helpers for authentication of user.
 
static getUserId()
Get the current user's id.
 
static getGroupId()
Get the current user's group id.
 
showRow($row, Request $request, $uri, $menuPfile, $menuPfileNoCompare, $statusTypesAvailable, $users, $rowCounter)
 
handle(Request $request)
Display the loaded menu and plugins.
 
createSelectUsers($selectElementName, $databaseMap, $selectedValue, $action="")
 
getListOfUploadsOfFolder(Request $request)
 
respondFolderGetTableData(Request $request)
 
getIntegerFilter($var, $columnName)
 
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk).
 
Traceback_uri()
Get the URI without query to this location.
 
Convert2BrowserTime($server_time)
Convert the server time to browser time.
 
fo_dbManager * dbManager
fo_dbManager object