14 use Symfony\Component\HttpFoundation\JsonResponse;
44 function __construct($uploadTreeTableName)
47 $this->dataTablesUtility = $container->get(
'utils.data_tables_utility');
48 $this->uploadDao = $container->get(
'dao.upload');
49 $this->
dbManager = $container->get(
'db.manager');
50 $this->copyrightDao = $container->get(
'dao.copyright');
64 public function doGetData($type, $upload, $activated =
true)
70 list ($aaData, $iTotalRecords, $iTotalDisplayRecords) = $this->
getTableData(
71 $upload, $item, $type, $listPage, $filter, $activated);
72 return new JsonResponse(
74 'sEcho' => intval($_GET[
'sEcho']),
76 'iTotalRecords' => $iTotalRecords,
77 'iTotalDisplayRecords' => $iTotalDisplayRecords
92 private function getTableData($upload, $item, $type, $listPage, $filter,
95 list ($rows, $iTotalDisplayRecords, $iTotalRecords) = $this->
getTextFindings(
100 foreach ($rows as $row) {
101 $aaData[] = $this->
fillTableRow($row, $upload, $item, $type, $listPage,
109 $iTotalDisplayRecords
124 $uploadTreeTableName, $filter, $activated =
true)
132 list ($left, $right) = $this->uploadDao->getLeftAndRight($item,
133 $uploadTreeTableName);
140 if (
'uploadtree_a' == $uploadTreeTableName) {
141 $sql_upload =
" AND UT.upload_fk = $upload_pk ";
146 if ($filter ==
"nolic") {
147 $noLicStr =
"No_license_found";
148 $voidLicStr =
"Void";
149 $join =
" INNER JOIN license_file AS LF on cp.pfile_fk = LF.pfile_fk ";
150 $filterQuery =
" AND LF.rf_fk IN (" .
"SELECT rf_pk FROM license_ref " .
151 "WHERE rf_shortname IN ('$noLicStr','$voidLicStr')) ";
159 $filterParms = $params;
161 $unorderedQuery =
"FROM $tableName AS cp " .
162 "INNER JOIN $uploadTreeTableName AS UT ON cp.pfile_fk = UT.pfile_fk " .
163 $join .
"WHERE cp.textfinding != '' " .
164 "AND ( UT.lft BETWEEN $1 AND $2 ) " .
"AND cp.is_enabled = " .
165 ($activated ?
'true' :
'false') . $sql_upload;
166 $totalFilter = $filterQuery .
" " . $searchFilter;
168 $grouping =
" GROUP BY hash ";
170 $countQuery =
"SELECT count(*) FROM (SELECT hash $unorderedQuery $totalFilter $grouping) as K";
171 $iTotalDisplayRecordsRow = $this->
dbManager->getSingleRow($countQuery,
173 __METHOD__ . $tableName .
".count" . ($activated ?
'' :
'_deactivated'));
174 $iTotalDisplayRecords = $iTotalDisplayRecordsRow[
'count'];
176 $countAllQuery =
"SELECT count(*) FROM (SELECT hash $unorderedQuery$grouping) as K";
177 $iTotalRecordsRow = $this->
dbManager->getSingleRow($countAllQuery, $params,
178 __METHOD__, $tableName .
"count.all" . ($activated ?
'' :
'_deactivated'));
179 $iTotalRecords = $iTotalRecordsRow[
'count'];
182 $filterParms[] = $offset;
183 $range .=
' OFFSET $' . count($filterParms);
184 $filterParms[] = $limit;
185 $range .=
' LIMIT $' . count($filterParms);
187 $sql =
"SELECT textfinding, hash, count(*) as textfinding_count " .
188 $unorderedQuery . $totalFilter .
189 " GROUP BY textfinding, hash " . $orderString .
191 $statement = __METHOD__ . $filter . $tableName . $uploadTreeTableName .
192 ($activated ?
'' :
'_deactivated');
193 $this->
dbManager->prepare($statement, $sql);
194 $result = $this->
dbManager->execute($statement, $filterParms);
195 $rows = $this->
dbManager->fetchAll($result);
200 $iTotalDisplayRecords,
211 $columnNamesInDatabase = array(
218 return $this->dataTablesUtility->getSortingString($_GET,
219 $columnNamesInDatabase, $defaultOrder);
230 if (empty($searchPattern)) {
233 $filterParams[] =
"%$searchPattern%";
234 return ' AND CP.content ilike $' . count($filterParams) .
' ';
253 $act .=
" hidden='true'";
255 $act .=
" id='deleteHashDecision$ajaxType$hash' " .
256 "onClick='event.preventDefault();deleteHashDecision(\"$hash\",$upload,\"" .
257 $ajaxType .
"\");' class=\"delete\" src=\"images/space_16.png\">";
260 $act .=
" hidden='true'";
262 $act .=
" id='undoDeleteHashDecision$ajaxType$hash'> " .
263 "deactivated [<a href=\"#\" class='undo$type' " .
264 "onClick='event.preventDefault();undoHashDecision(\"$hash\",$upload,\"" .
265 $ajaxType .
"\");return false;'>Undo</a>]</span>";
269 return "deactivated";
286 $activated =
true, $rw =
true)
288 $hash = $row[
'hash'];
289 $sql =
"SELECT pfile_fk FROM " . $this->
getTableName($type) .
291 $statement = __METHOD__ .
".getPfiles";
292 $decisions = $this->
dbManager->getRows($sql, [$hash], $statement);
294 foreach ($decisions as $decision) {
295 $pfileIds[] = $decision[
'pfile_fk'];
303 $link .=
"?mod=$listPage&agent=-1&item=$item" .
304 "&hash=$hash&type=$type&filter=all";
305 $link .=
"'>". intval($row[
'textfinding_count']) .
"</a>";
306 $output[
'0'] = $link;
310 if ($rw && $activated) {
311 $output[
'3'] =
"<input type='checkbox' class='deleteBySelect$type' " .
312 "id='deleteBySelectfinding$hash' value='$hash,$upload," .
315 $output[
'3'] =
"<input type='checkbox' class='undoBySelect$type' " .
316 "id='undoBySelectfinding$hash' value='$hash,$upload," .
331 return "copyright_decision";
355 return "copyright-list";
char * uploadtree_tablename
upload.uploadtree_tablename
Create histogram plugin for copyright.
Handles Ajax requests for text findings.
getOrderString()
Create sorting string for database query.
getViewName($type)
Get name of view for links.
getTableRowAction($hash, $upload, $type, $activated=true, $rw=true)
Helper to create action column for results.
getTableData($upload, $item, $type, $listPage, $filter, $activated=true)
Get the text finding data and fill in expected format.
getDecisionTypeName($type)
Get type name for ajax calls based.
getTableName($type)
Get table name based on decision type.
addSearchFilter(&$filterParams)
Add filter on content.
getTextFindings($upload_pk, $item, $type, $uploadTreeTableName, $filter, $activated=true)
Get results from database and format for JSON.
fillTableRow($row, $upload, $item, $type, $listPage, $activated=true, $rw=true)
Fill table content for JSON response.
doGetData($type, $upload, $activated=true)
Handles GET request and create a JSON response.
Contains the constants and helpers for authentication of user.
static getGroupId()
Get the current user's group id.
static returnSortOrder()
Get sorting orders.
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
if(! defined('ENT_SUBSTITUTE')) convertToUTF8($content, $toHTML=true)
fo_dbManager * dbManager
fo_dbManager object
Namespace for Copyright agent's UI components.