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"
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"
85 private $checkBoxListSPDX = array(
86 "spdxLicenseComment" =>
"spdxLicenseComment",
87 "ignoreFilesWOInfo" =>
"ignoreFilesWOInfo",
88 "osselotExport" =>
"osselotExport"
94 $this->Name =
"report_conf";
95 $this->Title = _(
"Report Configuration");
96 $this->Dependency = array(
"browse");
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');
112 $tooltipText = _(
"Report Configuration");
113 menu_insert(
"Browse-Pfile::Conf",5,$this->Name,$tooltipText);
116 $URI = $this->Name . $Parm;
126 menu_insert(
"View-Meta::{$menuText}", $menuPosition);
130 $tooltipText = _(
"Report Configuration");
133 menu_insert(
"View::{$menuText}", $menuPosition, $URI, $tooltipText);
136 menu_insert(
"View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
138 menu_insert(
"Browse::Conf", -3, $URI, $tooltipText);
151 $row = $this->uploadDao->getReportInfo($uploadId);
152 foreach ($this->mapDBColumns as $key => $value) {
153 $vars[$key] = $row[$value];
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;
162 if ($row[
'ri_exportnotes'] ==
'NA' || empty($row[
'ri_exportnotes'])) {
163 $vars[
'styleExportTA'] = $textAreaNoneStyle;
166 if ($row[
'ri_copyrightnotes'] ==
'NA' || empty($row[
'ri_copyrightnotes'])) {
167 $vars[
'styleRestrictionTA'] = $textAreaNoneStyle;
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];
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];
183 foreach (array_keys($this->checkBoxListSPDX) as $key) {
184 $vars[$key] =
'unchecked';
188 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
189 $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
190 $allClearingDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId);
193 $excludedObligations = array();
194 $excludedObligations = (array) json_decode($row[
'ri_excluded_obligations'],
true);
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 />';
203 $tableRows .=
'<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).
'][]" value="'.$value.
'"> '.$value.
'<br />';
206 $tableRows .=
'</td></tr>';
208 $tableRowsUnifiedReport =
"";
209 $unifiedColumns = array();
210 if (!empty($row[
'ri_unifiedcolumns'])) {
211 $unifiedColumns = (array) json_decode($row[
'ri_unifiedcolumns'],
true);
213 $unifiedColumns = UploadDao::UNIFIED_REPORT_HEADINGS;
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>';
221 $checked =
'checked';
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>';
228 $tableRowsClixmlReport =
"";
229 $clixmlColumns = array();
230 if (!empty($row[
'ri_clixmlcolumns'])) {
231 $clixmlColumns = (array) json_decode($row[
'ri_clixmlcolumns'],
true);
233 $clixmlColumns = UploadDao::CLIXML_REPORT_HEADINGS;
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>';
241 $checked =
'checked';
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>';
248 if (!empty($row[
'ri_globaldecision'])) {
249 $vars[
'applyGlobal'] =
"checked";
251 $vars[
'tableRows'] = $tableRows;
252 $vars[
'tableRowsUnifiedReport'] = $tableRowsUnifiedReport;
253 $vars[
'tableRowsClixmlReport'] = $tableRowsClixmlReport;
268 foreach ($clearingDecisions as $clearingDecision) {
269 if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
272 $uploadTreeId = $clearingDecision->getUploadTreeId();
273 foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
274 if ($clearingLicense->isRemoved()) {
277 $ack = $clearingLicense->getAcknowledgement();
278 if (empty(
trim($ack))) {
281 if (!isset($ackData[$ack])) {
282 $ackData[$ack] = array(
'files' => array(),
'licenses' => array());
284 $ackData[$ack][
'files'][$uploadTreeId] =
true;
285 $ackData[$ack][
'licenses'][$clearingLicense->getShortName()] =
true;
289 foreach ($ackData as $ack => $data) {
290 $result[$ack] = array(
291 'count' => count($data[
'files']),
292 'licenses' => array_keys($data[
'licenses'])
308 foreach ($acknowledgements as $ackText => $ackData) {
309 $ackHtml = htmlspecialchars($ackText, ENT_QUOTES);
310 $licensesHtml = htmlspecialchars(implode(
', ', $ackData[
'licenses']));
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>';
337 $allClearedLicenses = array();
339 foreach ($clearingDecisions as $clearingDecision) {
340 if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
343 foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
344 if ($clearingLicense->isRemoved()) {
347 $allClearedLicenses[$licenseMap->getProjectedId($clearingLicense->getLicenseId())] =
true;
350 $uniqueLicenseIds = array_keys($allClearedLicenses);
351 $allObligations = array_merge(
352 $this->licenseDao->getLicenseObligations($uniqueLicenseIds) ?: array(),
353 $this->licenseDao->getLicenseObligations($uniqueLicenseIds,
true) ?: array()
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;
363 $groupedObligations[$groupBy] = array(
364 "topic" => $obligation[
'ob_topic'],
365 "text" => $obligation[
'ob_text'],
366 "license" => array($licenseName =>
true)
370 foreach ($groupedObligations as &$ob) {
371 $ob[
'license'] = array_keys($ob[
'license']);
373 return $groupedObligations;
382 foreach ($listParams as $listkey => $listValue) {
384 if ($ret != $listkey) {
385 $cbList[] =
"unchecked";
387 $cbList[] =
"checked";
390 $cbSelectionList = implode(
",", $cbList);
392 return $cbSelectionList;
398 $groupId = Auth::getGroupId();
399 $userId = Auth::getUserId();
400 if (!$this->uploadDao->isAccessible($uploadId, $groupId)) {
405 $this->vars[
'micromenu'] =
Dir2Browse(
"browse", $itemId, NULL, $showBox=0,
"View-Meta");
406 $this->vars[
'globalClearingAvailable'] = Auth::isClearingAdmin();
410 if (isset($submitReportConf)) {
411 $applyGlobal = @$_POST[
"applyGlobal"];
412 $applyGlobal = !empty($applyGlobal) ? 1 : 0;
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;
424 foreach ($this->mapDBColumns as $key => $value) {
425 $columns .= $value.
" = $".$i.
", ";
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);
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);
441 $checkBoxUrPos = count($parms);
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);
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");
466 if (@$_POST[
'markGlobal']) {
467 $upload = $this->uploadDao->getUpload($uploadId);
468 $uploadName = $upload->getFilename();
469 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
472 $conflictStrategyId =
"global";
474 $deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
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>";
483 $this->vars[
'typemap'] = [];
484 foreach (ComponentType::TYPE_MAP as $key => $name) {
485 if ($key == ComponentType::PACKAGEURL) {
488 $this->vars[
'typemap'][] = [
'key' => $key,
'name' => $name];
492 public function getTemplateName()
494 return "ui-report-conf.html.twig";
505 var reportTabCookie = 'stickyReportTab';
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();
519 $('#reportConfSubmit').show();
524 var activeIdx = $.cookie(reportTabCookie) || 0;
525 if ($(\"#confTabs .ui-tabs-panel\").eq(activeIdx).attr('id') === 'acknowledgementsConfTab') {
526 $('#reportConfSubmit').hide();
528 $(\"input[name='dependencySourceBinary']\").change(function(){
529 var val = $(\"input[name='dependencySourceBinary']:checked\").val();
530 if (val == 'noDependency') {
531 $('#dependencyBinarySource').hide();
532 $('#dependencyBinarySource').val('');
534 $('#dependencyBinarySource').css('display', 'block');
537 $(\"input[name='exportRestriction']\").change(function(){
538 var val = $(\"input[name='exportRestriction']:checked\").val();
539 if (val == 'noExportRestriction') {
540 $('#exportRestrictionText').hide();
541 $('#exportRestrictionText').val('');
543 $('#exportRestrictionText').css('display', 'block');
546 $(\"input[name='restrictionForUse']\").change(function(){
547 var val = $(\"input[name='restrictionForUse']:checked\").val();
548 if (val == 'noRestriction') {
549 $('#copyrightRestrictionText').hide();
550 $('#copyrightRestrictionText').val('');
552 $('#copyrightRestrictionText').css('display', 'block');
556 $('#osselotExportCheckbox').change(function() {
557 if ($(this).is(':checked')) {
558 $('#spdxLicenseCommentCheckbox').prop('checked', true);
561 $(\"[data-toggle='tooltip']\").tooltip();
562 $('#spdxLicenseCommentCheckbox').change(function() {
564 $('#osselotExportCheckbox').prop('checked', false);
568 var ackAjaxUrl = '?mod=ajax-acknowledgement-conf';
570 $(document).on('click', '.ack-count-link', function(e) {
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},
579 if (!data || data.length === 0) {
580 $('#ackFilesModalCount').text('');
581 $('#ackFilesModalBody').html('<p>No files found.</p>');
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()
593 html += '</tbody></table>';
594 $('#ackFilesModalBody').html(html);
597 $('#ackFilesModalCount').text('');
598 $('#ackFilesModalBody').html('<p>Error loading files.</p>');
602 $(document).on('dblclick', '.ack-text-area', function() {
603 if (!$(this).prop('readonly')) {
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>'
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();
626 var upload = row.find('.ack-count-link').data('upload');
628 {action: 'updateAcknowledgement', upload: upload, oldAck: oldAck, newAck: newAck},
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]) {
638 .data('original-ack', newAck)
639 .prop('readonly', true)
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();
645 alert('Failed to update acknowledgement.');
649 alert('Error communicating with server.');
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)
659 td.find('.ack-edit-actions').remove();
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?')) {
668 var row = $(this).closest('tr');
670 {action: 'deleteAcknowledgement', upload: upload, ack: ack},
672 if (data && data.status === 'success') {
673 row.fadeOut(400, function() { row.remove(); });
675 alert('Failed to delete acknowledgement.');
679 alert('Error communicating with server.');
688 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Output()
This function is called when user output is requested. This function is responsible for content....
Contains the constants and helpers for authentication of user.
Wrapper class for license map.
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.
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
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.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
fo_dbManager * dbManager
fo_dbManager object