FOSSology  4.7.0-rc1
Open Source License Compliance by Open Source Software
ui-report-conf.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2019 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
18 
20 {
21 
23  private $dbManager;
24 
28  private $uploadDao;
29 
32  private $userDao;
33 
37  private $licenseDao;
38 
42  private $clearingDao;
43 
47  private $mapDBColumns = array(
48  "reviewedBy" => "ri_reviewed",
49  "department" => "ri_department",
50  "reportRel" => "ri_report_rel",
51  "community" => "ri_community",
52  "component" => "ri_component",
53  "version" => "ri_version",
54  "relDate" => "ri_release_date",
55  "sw360Link" => "ri_sw360_link",
56  "componentType" => "ri_component_type",
57  "componentId" => "ri_component_id",
58  "footerNote" => "ri_footer",
59  "generalAssesment" => "ri_general_assesment",
60  "gaAdditional" => "ri_ga_additional",
61  "gaRisk" => "ri_ga_risk",
62  "dependencyBinarySource" => "ri_depnotes",
63  "exportRestrictionText" => "ri_exportnotes",
64  "copyrightRestrictionText" => "ri_copyrightnotes"
65  );
66 
70  private $radioListUR = array(
71  "nonCritical" => "critical",
72  "critical" => "critical",
73  "noDependency" => "dependencySourceBinary",
74  "dependencySource" => "dependencySourceBinary",
75  "dependencyBinary" => "dependencySourceBinary",
76  "noExportRestriction" => "exportRestriction",
77  "exportRestriction" => "exportRestriction",
78  "noRestriction" => "restrictionForUse",
79  "restrictionForUse" => "restrictionForUse"
80  );
81 
85  private $checkBoxListSPDX = array(
86  "spdxLicenseComment" => "spdxLicenseComment",
87  "ignoreFilesWOInfo" => "ignoreFilesWOInfo",
88  "osselotExport" => "osselotExport"
89  );
90 
91 
92  function __construct()
93  {
94  $this->Name = "report_conf";
95  $this->Title = _("Report Configuration");
96  $this->Dependency = array("browse");
97  $this->DBaccess = PLUGIN_DB_READ;
98  $this->LoginFlag = 0;
99  parent::__construct();
100  $this->uploadDao = $GLOBALS['container']->get('dao.upload');
101  $this->dbManager = $GLOBALS['container']->get('db.manager');
102  $this->userDao = $GLOBALS['container']->get('dao.user');
103  $this->clearingDao = $GLOBALS['container']->get('dao.clearing');
104  $this->licenseDao = $GLOBALS['container']->get('dao.license');
105  }
106 
110  function RegisterMenus()
111  {
112  $tooltipText = _("Report Configuration");
113  menu_insert("Browse-Pfile::Conf",5,$this->Name,$tooltipText);
114  // For the Browse menu, permit switching between detail and summary.
115  $Parm = Traceback_parm_keep(array("upload","item","format"));
116  $URI = $this->Name . $Parm;
117 
118  $menuPosition = 60;
119  $menuText = "Conf";
120  if (GetParm("mod", PARM_STRING) == $this->Name) {
121  menu_insert("View::[BREAK]", 61);
122  menu_insert("View::[BREAK]", 50);
123  menu_insert("View::{$menuText}", $menuPosition);
124  menu_insert("View-Meta::[BREAK]", 61);
125  menu_insert("View-Meta::[BREAK]", 50);
126  menu_insert("View-Meta::{$menuText}", $menuPosition);
127 
128  menu_insert("Browse::Conf",-3);
129  } else {
130  $tooltipText = _("Report Configuration");
131  menu_insert("View::[BREAK]", 61);
132  menu_insert("View::[BREAK]", 50);
133  menu_insert("View::{$menuText}", $menuPosition, $URI, $tooltipText);
134  menu_insert("View-Meta::[BREAK]", 61);
135  menu_insert("View-Meta::[BREAK]", 50);
136  menu_insert("View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
137 
138  menu_insert("Browse::Conf", -3, $URI, $tooltipText);
139  }
140  } // RegisterMenus()
141 
148  function allReportConfiguration($uploadId, $groupId)
149  {
150  $vars = [];
151  $row = $this->uploadDao->getReportInfo($uploadId);
152  foreach ($this->mapDBColumns as $key => $value) {
153  $vars[$key] = $row[$value];
154  }
155  $textAreaNoneStyle = ' style="display:none;overflow:auto;width:98%;height:80px;"';
156  $textAreaStyle = ' style="overflow:auto;width:98%;height:80px;"';
157  $vars['styleDependencyTA'] = $vars['styleExportTA'] = $vars['styleRestrictionTA'] = $textAreaStyle;
158  if ($row['ri_depnotes'] == 'NA' || empty($row['ri_depnotes'])) {
159  $vars['styleDependencyTA'] = $textAreaNoneStyle;
160  }
161 
162  if ($row['ri_exportnotes'] == 'NA' || empty($row['ri_exportnotes'])) {
163  $vars['styleExportTA'] = $textAreaNoneStyle;
164  }
165 
166  if ($row['ri_copyrightnotes'] == 'NA' || empty($row['ri_copyrightnotes'])) {
167  $vars['styleRestrictionTA'] = $textAreaNoneStyle;
168  }
169 
170  if (!empty($row['ri_ga_checkbox_selection'])) {
171  $listURCheckbox = explode(',', $row['ri_ga_checkbox_selection']);
172  foreach (array_keys($this->radioListUR) as $key => $value) {
173  $vars[$value] = $listURCheckbox[$key];
174  }
175  }
176 
177  if (!empty($row['ri_spdx_selection'])) {
178  $listSPDXCheckbox = explode(',', $row['ri_spdx_selection']);
179  foreach (array_keys($this->checkBoxListSPDX) as $key => $value) {
180  $vars[$value] = $listSPDXCheckbox[$key];
181  }
182  } else {
183  foreach (array_keys($this->checkBoxListSPDX) as $key) {
184  $vars[$key] = 'unchecked';
185  }
186  }
187 
188  $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
189  $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
190  $allClearingDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId);
191 
192  $tableRows = "";
193  $excludedObligations = array();
194  $excludedObligations = (array) json_decode($row['ri_excluded_obligations'], true);
195  foreach ($this->getAllObligationsForGivenUploadId($groupId, $allClearingDecisions) as $obTopic => $obData) {
196  $tableRows .= '<tr><td style="width:35%">'.$obTopic.'</td>';
197  $tableRows .= '<td><textarea readonly="readonly" style="overflow:auto;width:98%;height:80px;">'.
198  $obData['text'].'</textarea></td><td>';
199  foreach ($obData['license'] as $value) {
200  if (!empty($excludedObligations[$obTopic]) && in_array($value, $excludedObligations[$obTopic])) {
201  $tableRows .= '<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).'][]" value="'.$value.'" checked> '.$value.'<br />';
202  } else {
203  $tableRows .= '<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).'][]" value="'.$value.'"> '.$value.'<br />';
204  }
205  }
206  $tableRows .= '</td></tr>';
207  }
208  $tableRowsUnifiedReport = "";
209  $unifiedColumns = array();
210  if (!empty($row['ri_unifiedcolumns'])) {
211  $unifiedColumns = (array) json_decode($row['ri_unifiedcolumns'], true);
212  } else {
213  $unifiedColumns = UploadDao::UNIFIED_REPORT_HEADINGS;
214  }
215  foreach ($unifiedColumns as $name => $unifiedReportColumns) {
216  foreach ($unifiedReportColumns as $columnName => $isenabled) {
217  $tableRowsUnifiedReport .= '<tr>';
218  $tableRowsUnifiedReport .= '<td><input class="form-control" type="text" style="width:95%" name="'.$name.'[]" value="'.$columnName.'"></td>';
219  $checked = '';
220  if ($isenabled) {
221  $checked = 'checked';
222  }
223  $tableRowsUnifiedReport .= '<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.'[]" '.$checked.'></td>';
224  $tableRowsUnifiedReport .= '</tr>';
225  }
226  }
227 
228  $tableRowsClixmlReport = "";
229  $clixmlColumns = array();
230  if (!empty($row['ri_clixmlcolumns'])) {
231  $clixmlColumns = (array) json_decode($row['ri_clixmlcolumns'], true);
232  } else {
233  $clixmlColumns = UploadDao::CLIXML_REPORT_HEADINGS;
234  }
235  foreach ($clixmlColumns as $name => $clixmlReportColumns) {
236  foreach ($clixmlReportColumns as $columnName => $isenabled) {
237  $tableRowsClixmlReport .= '<tr>';
238  $tableRowsClixmlReport .= '<td><input class="form-control" type="text" style="width:95%" name="'.$name.'[]" value="'.$columnName.'" readonly></td>';
239  $checked = '';
240  if ($isenabled) {
241  $checked = 'checked';
242  }
243  $tableRowsClixmlReport .= '<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.'[]" '.$checked.'></td>';
244  $tableRowsClixmlReport .= '</tr>';
245  }
246  }
247 
248  if (!empty($row['ri_globaldecision'])) {
249  $vars['applyGlobal'] = "checked";
250  }
251  $vars['tableRows'] = $tableRows;
252  $vars['tableRowsUnifiedReport'] = $tableRowsUnifiedReport;
253  $vars['tableRowsClixmlReport'] = $tableRowsClixmlReport;
254  $vars['ackRows'] = $this->buildAcknowledgementRows($uploadId, $allClearingDecisions);
255  $vars['scriptBlock'] = $this->createScriptBlock();
256 
257  return $vars;
258  }
259 
265  function getAllAcknowledgementsForUpload(array $clearingDecisions)
266  {
267  $ackData = array();
268  foreach ($clearingDecisions as $clearingDecision) {
269  if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
270  continue;
271  }
272  $uploadTreeId = $clearingDecision->getUploadTreeId();
273  foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
274  if ($clearingLicense->isRemoved()) {
275  continue;
276  }
277  $ack = $clearingLicense->getAcknowledgement();
278  if (empty(trim($ack))) {
279  continue;
280  }
281  if (!isset($ackData[$ack])) {
282  $ackData[$ack] = array('files' => array(), 'licenses' => array());
283  }
284  $ackData[$ack]['files'][$uploadTreeId] = true;
285  $ackData[$ack]['licenses'][$clearingLicense->getShortName()] = true;
286  }
287  }
288  $result = array();
289  foreach ($ackData as $ack => $data) {
290  $result[$ack] = array(
291  'count' => count($data['files']),
292  'licenses' => array_keys($data['licenses'])
293  );
294  }
295  return $result;
296  }
297 
304  function buildAcknowledgementRows($uploadId, array $clearingDecisions)
305  {
306  $acknowledgements = $this->getAllAcknowledgementsForUpload($clearingDecisions);
307  $rows = "";
308  foreach ($acknowledgements as $ackText => $ackData) {
309  $ackHtml = htmlspecialchars($ackText, ENT_QUOTES);
310  $licensesHtml = htmlspecialchars(implode(', ', $ackData['licenses']));
311  $rows .= '<tr>';
312  $rows .= '<td style="width:5%;text-align:center">'
313  . '<a href="#" class="ack-count-link" data-upload="' . $uploadId
314  . '" data-ack="' . $ackHtml . '">' . $ackData['count'] . '</a></td>';
315  $rows .= '<td style="width:60%"><textarea class="ack-text-area" readonly="readonly"'
316  . ' data-original-ack="' . $ackHtml . '"'
317  . ' style="overflow:auto;width:98%;height:60px;">'
318  . $ackHtml . '</textarea></td>';
319  $rows .= '<td style="width:25%">' . $licensesHtml . '</td>';
320  $rows .= '<td style="width:10%;text-align:center">'
321  . '<button type="button" class="btn btn-danger btn-sm delete-ack-btn"'
322  . ' data-upload="' . $uploadId . '" data-ack="' . $ackHtml . '">'
323  . 'Delete</button></td>';
324  $rows .= '</tr>';
325  }
326  return $rows;
327  }
328 
335  function getAllObligationsForGivenUploadId($groupId, array $clearingDecisions)
336  {
337  $allClearedLicenses = array();
338  $licenseMap = new LicenseMap($this->dbManager, $groupId, LicenseMap::REPORT);
339  foreach ($clearingDecisions as $clearingDecision) {
340  if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
341  continue;
342  }
343  foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
344  if ($clearingLicense->isRemoved()) {
345  continue;
346  }
347  $allClearedLicenses[$licenseMap->getProjectedId($clearingLicense->getLicenseId())] = true;
348  }
349  }
350  $uniqueLicenseIds = array_keys($allClearedLicenses);
351  $allObligations = array_merge(
352  $this->licenseDao->getLicenseObligations($uniqueLicenseIds) ?: array(),
353  $this->licenseDao->getLicenseObligations($uniqueLicenseIds, true) ?: array()
354  );
355  $groupedObligations = array();
356  foreach ($allObligations as $obligation) {
357  $groupBy = $obligation['ob_topic'];
358  $licenseName = LicenseRef::convertToSpdxId($obligation['rf_shortname'],
359  $obligation['rf_spdx_id']);
360  if (array_key_exists($groupBy, $groupedObligations)) {
361  $groupedObligations[$groupBy]['license'][$licenseName] = true;
362  } else {
363  $groupedObligations[$groupBy] = array(
364  "topic" => $obligation['ob_topic'],
365  "text" => $obligation['ob_text'],
366  "license" => array($licenseName => true)
367  );
368  }
369  }
370  foreach ($groupedObligations as &$ob) {
371  $ob['license'] = array_keys($ob['license']);
372  }
373  return $groupedObligations;
374  }
375 
380  protected function getCheckBoxSelectionList($listParams)
381  {
382  foreach ($listParams as $listkey => $listValue) {
383  $ret = GetParm($listValue, PARM_STRING);
384  if ($ret != $listkey) {
385  $cbList[] = "unchecked";
386  } else {
387  $cbList[] = "checked";
388  }
389  }
390  $cbSelectionList = implode(",", $cbList);
391 
392  return $cbSelectionList;
393  }
394 
395  public function Output()
396  {
397  $uploadId = GetParm("upload", PARM_INTEGER);
398  $groupId = Auth::getGroupId();
399  $userId = Auth::getUserId();
400  if (!$this->uploadDao->isAccessible($uploadId, $groupId)) {
401  return;
402  }
403 
404  $itemId = GetParm("item",PARM_INTEGER);
405  $this->vars['micromenu'] = Dir2Browse("browse", $itemId, NULL, $showBox=0, "View-Meta");
406  $this->vars['globalClearingAvailable'] = Auth::isClearingAdmin();
407 
408  $submitReportConf = GetParm("submitReportConf", PARM_STRING);
409 
410  if (isset($submitReportConf)) {
411  $applyGlobal = @$_POST["applyGlobal"];
412  $applyGlobal = !empty($applyGlobal) ? 1 : 0;
413  $parms = array();
414  $obLicensesEncoded = @$_POST["obLicenses"];
415  $obLicensesEncoded = !empty($obLicensesEncoded) ? $obLicensesEncoded : array();
416  $obLicenses = array();
417  array_walk($obLicensesEncoded,
418  function (&$licArray, $obTopic) use (&$obLicenses) {
419  $obLicenses[urldecode($obTopic)] = $licArray;
420  }
421  );
422  $i = 1;
423  $columns = "";
424  foreach ($this->mapDBColumns as $key => $value) {
425  $columns .= $value." = $".$i.", ";
426  $parms[] = GetParm($key, PARM_RAW);
427  $i++;
428  }
429  $parms[] = $this->getCheckBoxSelectionList($this->radioListUR);
430 
431  $unifiedReportColumnsForJson = array();
432  foreach (UploadDao::UNIFIED_REPORT_HEADINGS as $columnName => $columnValue) {
433  $columnResult = @$_POST[$columnName];
434  $unifiedReportColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] : null);
435  }
436  $clixmlColumnsForJson = array();
437  foreach (UploadDao::CLIXML_REPORT_HEADINGS as $columnName => $columnValue) {
438  $columnResult = @$_POST[$columnName];
439  $clixmlColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] : null);
440  }
441  $checkBoxUrPos = count($parms);
442  $parms[] = $this->getCheckBoxSelectionList($this->checkBoxListSPDX);
443  $checkBoxSpdxPos = count($parms);
444  $parms[] = json_encode($obLicenses);
445  $excludeObligationPos = count($parms);
446  $parms[] = json_encode($unifiedReportColumnsForJson);
447  $unifiedColumnsPos = count($parms);
448  $parms[] = json_encode($clixmlColumnsForJson);
449  $clixmlColumnsPos = count($parms);
450  $parms[] = $applyGlobal;
451  $applyGlobalPos = count($parms);
452  $parms[] = $uploadId;
453  $uploadIdPos = count($parms);
454 
455  $SQL = "UPDATE report_info SET $columns" .
456  "ri_ga_checkbox_selection = $$checkBoxUrPos, " .
457  "ri_spdx_selection = $$checkBoxSpdxPos, " .
458  "ri_excluded_obligations = $$excludeObligationPos, " .
459  "ri_unifiedcolumns = $$unifiedColumnsPos, " .
460  "ri_clixmlcolumns = $$clixmlColumnsPos, " .
461  "ri_globaldecision = $$applyGlobalPos " .
462  "WHERE upload_fk = $$uploadIdPos;";
463  $this->dbManager->getSingleRow($SQL, $parms,
464  __METHOD__ . "updateReportInfoData");
465 
466  if (@$_POST['markGlobal']) {
467  $upload = $this->uploadDao->getUpload($uploadId);
468  $uploadName = $upload->getFilename();
469  $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
471  $deciderPlugin = plugin_find("agent_deciderjob");
472  $conflictStrategyId = "global";
473  $errorMsg = "";
474  $deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
475  $schedulerMsg = empty(GetRunnableJobList()) ? _("Is the scheduler running? ") : '';
476  $url = Traceback_uri() . "?mod=showjobs&upload=$uploadId";
477  $text = _("Your jobs have been added to job queue.");
478  $linkText = _("View Jobs");
479  $this->vars['message'] = "$schedulerMsg" . "$text <a href=\"$url\">$linkText</a>";
480  }
481  }
482  $this->vars += $this->allReportConfiguration($uploadId, $groupId);
483  $this->vars['typemap'] = [];
484  foreach (ComponentType::TYPE_MAP as $key => $name) {
485  if ($key == ComponentType::PACKAGEURL) {
486  continue;
487  }
488  $this->vars['typemap'][] = ['key' => $key, 'name' => $name];
489  }
490  }
491 
492  public function getTemplateName()
493  {
494  return "ui-report-conf.html.twig";
495  }
496 
501  protected function createScriptBlock()
502  {
503  return "
504 
505  var reportTabCookie = 'stickyReportTab';
506 
507  $(document).ready(function() {
508  $(\"#confTabs\").tabs({
509  active: ($.cookie(reportTabCookie) || 0),
510  activate: function(e, ui){
511  // Get active tab index and update cookie
512  var idString = $(e.currentTarget).attr('id');
513  idString = parseInt(idString.slice(-1)) - 1;
514  $.cookie(reportTabCookie, idString);
515  // Hide submit button on acknowledgements tab (AJAX-only tab)
516  if (ui.newPanel.attr('id') === 'acknowledgementsConfTab') {
517  $('#reportConfSubmit').hide();
518  } else {
519  $('#reportConfSubmit').show();
520  }
521  }
522  });
523 
524  var activeIdx = $.cookie(reportTabCookie) || 0;
525  if ($(\"#confTabs .ui-tabs-panel\").eq(activeIdx).attr('id') === 'acknowledgementsConfTab') {
526  $('#reportConfSubmit').hide();
527  }
528  $(\"input[name='dependencySourceBinary']\").change(function(){
529  var val = $(\"input[name='dependencySourceBinary']:checked\").val();
530  if (val == 'noDependency') {
531  $('#dependencyBinarySource').hide();
532  $('#dependencyBinarySource').val('');
533  } else {
534  $('#dependencyBinarySource').css('display', 'block');
535  }
536  });
537  $(\"input[name='exportRestriction']\").change(function(){
538  var val = $(\"input[name='exportRestriction']:checked\").val();
539  if (val == 'noExportRestriction') {
540  $('#exportRestrictionText').hide();
541  $('#exportRestrictionText').val('');
542  } else {
543  $('#exportRestrictionText').css('display', 'block');
544  }
545  });
546  $(\"input[name='restrictionForUse']\").change(function(){
547  var val = $(\"input[name='restrictionForUse']:checked\").val();
548  if (val == 'noRestriction') {
549  $('#copyrightRestrictionText').hide();
550  $('#copyrightRestrictionText').val('');
551  } else {
552  $('#copyrightRestrictionText').css('display', 'block');
553  }
554  });
555 
556  $('#osselotExportCheckbox').change(function() {
557  if ($(this).is(':checked')) {
558  $('#spdxLicenseCommentCheckbox').prop('checked', true);
559  }
560  });
561  $(\"[data-toggle='tooltip']\").tooltip();
562  $('#spdxLicenseCommentCheckbox').change(function() {
563  if (!this.checked) {
564  $('#osselotExportCheckbox').prop('checked', false);
565  }
566  });
567 
568  var ackAjaxUrl = '?mod=ajax-acknowledgement-conf';
569 
570  $(document).on('click', '.ack-count-link', function(e) {
571  e.preventDefault();
572  var upload = $(this).data('upload');
573  var ack = $(this).data('ack');
574  $('#ackFilesModalBody').html('<p>Loading...</p>');
575  $('#ackFilesModalCount').text('');
576  $('#ackFilesModal').modal('show');
577  $.get(ackAjaxUrl, {action: 'getFiles', upload: upload, ack: ack},
578  function(data) {
579  if (!data || data.length === 0) {
580  $('#ackFilesModalCount').text('');
581  $('#ackFilesModalBody').html('<p>No files found.</p>');
582  return;
583  }
584  $('#ackFilesModalCount').text('(' + data.length + ' files)');
585  var html = '<table class=\"table table-condensed table-hover\" style=\"margin:0;\">'
586  + '<thead><tr><th>#</th><th>File</th></tr></thead><tbody>';
587  $.each(data, function(i, file) {
588  html += '<tr><td>' + (i + 1) + '</td>'
589  + '<td><a href=\"' + file.url + '\" target=\"_blank\">'
590  + $('<span/>').text(file.name).html()
591  + '</a></td></tr>';
592  });
593  html += '</tbody></table>';
594  $('#ackFilesModalBody').html(html);
595  }
596  ).fail(function() {
597  $('#ackFilesModalCount').text('');
598  $('#ackFilesModalBody').html('<p>Error loading files.</p>');
599  });
600  });
601 
602  $(document).on('dblclick', '.ack-text-area', function() {
603  if (!$(this).prop('readonly')) {
604  return;
605  }
606  var ta = $(this);
607  var td = ta.closest('td');
608  ta.prop('readonly', false).css('border', '2px solid #337ab7').focus();
609  td.append('<div class=\"ack-edit-actions\" style=\"margin-top:4px;\">'
610  + '<button type=\"button\" class=\"btn btn-primary btn-xs ack-save-btn\">Save</button> '
611  + '<button type=\"button\" class=\"btn btn-default btn-xs ack-cancel-btn\">Cancel</button>'
612  + '</div>');
613  });
614 
615  $(document).on('click', '.ack-save-btn', function() {
616  var row = $(this).closest('tr');
617  var td = $(this).closest('td');
618  var ta = td.find('.ack-text-area');
619  var newAck = ta.val();
620  var oldAck = ta.data('original-ack');
621  if (newAck === oldAck) {
622  ta.prop('readonly', true).css('border', '');
623  td.find('.ack-edit-actions').remove();
624  return;
625  }
626  var upload = row.find('.ack-count-link').data('upload');
627  $.post(ackAjaxUrl,
628  {action: 'updateAcknowledgement', upload: upload, oldAck: oldAck, newAck: newAck},
629  function(data) {
630  if (data && data.status === 'success') {
631  $('#acknowledgementsConfTab tbody tr').each(function() {
632  if ($(this).find('.ack-text-area').data('original-ack') === newAck
633  && this !== row[0]) {
634  $(this).remove();
635  }
636  });
637  ta.val(newAck)
638  .data('original-ack', newAck)
639  .prop('readonly', true)
640  .css('border', '');
641  row.find('.ack-count-link').text(data.count).data('ack', newAck);
642  row.find('.delete-ack-btn').data('ack', newAck);
643  td.find('.ack-edit-actions').remove();
644  } else {
645  alert('Failed to update acknowledgement.');
646  }
647  }
648  ).fail(function() {
649  alert('Error communicating with server.');
650  });
651  });
652 
653  $(document).on('click', '.ack-cancel-btn', function() {
654  var td = $(this).closest('td');
655  var ta = td.find('.ack-text-area');
656  ta.val(ta.data('original-ack'))
657  .prop('readonly', true)
658  .css('border', '');
659  td.find('.ack-edit-actions').remove();
660  });
661 
662  $(document).on('click', '.delete-ack-btn', function() {
663  var upload = $(this).data('upload');
664  var ack = $(this).data('ack');
665  if (!confirm('Are you sure you want to clear this acknowledgement from all files?')) {
666  return;
667  }
668  var row = $(this).closest('tr');
669  $.post(ackAjaxUrl,
670  {action: 'deleteAcknowledgement', upload: upload, ack: ack},
671  function(data) {
672  if (data && data.status === 'success') {
673  row.fadeOut(400, function() { row.remove(); });
674  } else {
675  alert('Failed to delete acknowledgement.');
676  }
677  }
678  ).fail(function() {
679  alert('Error communicating with server.');
680  });
681  });
682  });
683  ";
684  }
685 }
686 
687 $NewPlugin = new ui_report_conf();
688 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Definition: FO_Plugin.php:57
Output()
This function is called when user output is requested. This function is responsible for content....
Definition: FO_Plugin.php:399
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24
Wrapper class for license map.
Definition: LicenseMap.php:19
getAllObligationsForGivenUploadId($groupId, array $clearingDecisions)
get all the obligations for cleared licenses
createScriptBlock()
Create Script block for conf.
buildAcknowledgementRows($uploadId, array $clearingDecisions)
Build HTML table rows for acknowledgements tab.
getAllAcknowledgementsForUpload(array $clearingDecisions)
Get acknowledgements for cleared licenses grouped by text.
allReportConfiguration($uploadId, $groupId)
list all the options for Report Configuration
RegisterMenus()
Customize submenus.
getCheckBoxSelectionList($listParams)
__construct()
base constructor. Most plugins will just use this
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Definition: common-dir.php:263
menu_insert($Path, $LastOrder=0, $URI=NULL, $Title=NULL, $Target=NULL, $HTML=NULL)
Given a Path, order level for the last item, and optional plugin name, insert the menu item.
Traceback_uri()
Get the URI without query to this location.
Definition: common-parm.php:97
const PARM_INTEGER
Definition: common-parm.php:14
const PARM_RAW
Definition: common-parm.php:22
const PARM_STRING
Definition: common-parm.php:18
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Definition: common-parm.php:46
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
GetRunnableJobList()
Get runnable job list, the process is below:
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:690
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
Definition: libfossology.h:37
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16