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';
189 $excludedObligations = array();
190 $excludedObligations = (array) json_decode($row[
'ri_excluded_obligations'],
true);
192 $tableRows .=
'<tr><td style="width:35%">'.$obTopic.
'</td>';
193 $tableRows .=
'<td><textarea readonly="readonly" style="overflow:auto;width:98%;height:80px;">'.
194 $obData[
'text'].
'</textarea></td><td>';
195 foreach ($obData[
'license'] as $value) {
196 if (!empty($excludedObligations[$obTopic]) && in_array($value, $excludedObligations[$obTopic])) {
197 $tableRows .=
'<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).
'][]" value="'.$value.
'" checked> '.$value.
'<br />';
199 $tableRows .=
'<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).
'][]" value="'.$value.
'"> '.$value.
'<br />';
202 $tableRows .=
'</td></tr>';
204 $tableRowsUnifiedReport =
"";
205 $unifiedColumns = array();
206 if (!empty($row[
'ri_unifiedcolumns'])) {
207 $unifiedColumns = (array) json_decode($row[
'ri_unifiedcolumns'],
true);
209 $unifiedColumns = UploadDao::UNIFIED_REPORT_HEADINGS;
211 foreach ($unifiedColumns as $name => $unifiedReportColumns) {
212 foreach ($unifiedReportColumns as $columnName => $isenabled) {
213 $tableRowsUnifiedReport .=
'<tr>';
214 $tableRowsUnifiedReport .=
'<td><input class="form-control" type="text" style="width:95%" name="'.$name.
'[]" value="'.$columnName.
'"></td>';
217 $checked =
'checked';
219 $tableRowsUnifiedReport .=
'<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.
'[]" '.$checked.
'></td>';
220 $tableRowsUnifiedReport .=
'</tr>';
224 $tableRowsClixmlReport =
"";
225 $clixmlColumns = array();
226 if (!empty($row[
'ri_clixmlcolumns'])) {
227 $clixmlColumns = (array) json_decode($row[
'ri_clixmlcolumns'],
true);
229 $clixmlColumns = UploadDao::CLIXML_REPORT_HEADINGS;
231 foreach ($clixmlColumns as $name => $clixmlReportColumns) {
232 foreach ($clixmlReportColumns as $columnName => $isenabled) {
233 $tableRowsClixmlReport .=
'<tr>';
234 $tableRowsClixmlReport .=
'<td><input class="form-control" type="text" style="width:95%" name="'.$name.
'[]" value="'.$columnName.
'" readonly></td>';
237 $checked =
'checked';
239 $tableRowsClixmlReport .=
'<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.
'[]" '.$checked.
'></td>';
240 $tableRowsClixmlReport .=
'</tr>';
244 if (!empty($row[
'ri_globaldecision'])) {
245 $vars[
'applyGlobal'] =
"checked";
247 $vars[
'tableRows'] = $tableRows;
248 $vars[
'tableRowsUnifiedReport'] = $tableRowsUnifiedReport;
249 $vars[
'tableRowsClixmlReport'] = $tableRowsClixmlReport;
263 $allClearedLicenses = array();
264 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
265 $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
266 $allClearingDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId);
268 foreach ($allClearingDecisions as $clearingDecisions) {
269 if ($clearingDecisions->getType() == DecisionTypes::IRRELEVANT) {
272 foreach ($clearingDecisions->getClearingLicenses() as $eachClearingLicense) {
273 if ($eachClearingLicense->isRemoved()) {
276 $getLicenseId = $eachClearingLicense->getLicenseId();
277 $allClearedLicenses[] = $licenseMap->getProjectedId($getLicenseId);
280 $obligationsForLicenses = $this->licenseDao->getLicenseObligations($allClearedLicenses) ?: array();
281 $obligationsForLicenseCandidates = $this->licenseDao->getLicenseObligations($allClearedLicenses,
true) ?: array();
282 $allObligations = array_merge($obligationsForLicenses, $obligationsForLicenseCandidates);
283 $groupedObligations = array();
284 foreach ($allObligations as $obligations) {
285 $groupBy = $obligations[
'ob_topic'];
286 $licenseName = LicenseRef::convertToSpdxId($obligations[
'rf_shortname'],
287 $obligations[
'rf_spdx_id']);
288 if (array_key_exists($groupBy, $groupedObligations)) {
289 $currentLicenses = &$groupedObligations[$groupBy][
'license'];
290 if (!in_array($licenseName, $currentLicenses)) {
291 $currentLicenses[] = $licenseName;
294 $groupedObligations[$groupBy] = array(
295 "topic" => $obligations[
'ob_topic'],
296 "text" => $obligations[
'ob_text'],
297 "license" => array($licenseName)
301 return $groupedObligations;
310 foreach ($listParams as $listkey => $listValue) {
312 if ($ret != $listkey) {
313 $cbList[] =
"unchecked";
315 $cbList[] =
"checked";
318 $cbSelectionList = implode(
",", $cbList);
320 return $cbSelectionList;
326 $groupId = Auth::getGroupId();
327 $userId = Auth::getUserId();
328 if (!$this->uploadDao->isAccessible($uploadId, $groupId)) {
333 $this->vars[
'micromenu'] =
Dir2Browse(
"browse", $itemId, NULL, $showBox=0,
"View-Meta");
334 $this->vars[
'globalClearingAvailable'] = Auth::isClearingAdmin();
338 if (isset($submitReportConf)) {
339 $applyGlobal = @$_POST[
"applyGlobal"];
340 $applyGlobal = !empty($applyGlobal) ? 1 : 0;
342 $obLicensesEncoded = @$_POST[
"obLicenses"];
343 $obLicensesEncoded = !empty($obLicensesEncoded) ? $obLicensesEncoded : array();
344 $obLicenses = array();
345 array_walk($obLicensesEncoded,
346 function (&$licArray, $obTopic) use (&$obLicenses) {
347 $obLicenses[urldecode($obTopic)] = $licArray;
352 foreach ($this->mapDBColumns as $key => $value) {
353 $columns .= $value.
" = $".$i.
", ";
359 $unifiedReportColumnsForJson = array();
360 foreach (UploadDao::UNIFIED_REPORT_HEADINGS as $columnName => $columnValue) {
361 $columnResult = @$_POST[$columnName];
362 $unifiedReportColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] :
null);
364 $clixmlColumnsForJson = array();
365 foreach (UploadDao::CLIXML_REPORT_HEADINGS as $columnName => $columnValue) {
366 $columnResult = @$_POST[$columnName];
367 $clixmlColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] :
null);
369 $checkBoxUrPos = count($parms);
371 $checkBoxSpdxPos = count($parms);
372 $parms[] = json_encode($obLicenses);
373 $excludeObligationPos = count($parms);
374 $parms[] = json_encode($unifiedReportColumnsForJson);
375 $unifiedColumnsPos = count($parms);
376 $parms[] = json_encode($clixmlColumnsForJson);
377 $clixmlColumnsPos = count($parms);
378 $parms[] = $applyGlobal;
379 $applyGlobalPos = count($parms);
380 $parms[] = $uploadId;
381 $uploadIdPos = count($parms);
383 $SQL =
"UPDATE report_info SET $columns" .
384 "ri_ga_checkbox_selection = $$checkBoxUrPos, " .
385 "ri_spdx_selection = $$checkBoxSpdxPos, " .
386 "ri_excluded_obligations = $$excludeObligationPos, " .
387 "ri_unifiedcolumns = $$unifiedColumnsPos, " .
388 "ri_clixmlcolumns = $$clixmlColumnsPos, " .
389 "ri_globaldecision = $$applyGlobalPos " .
390 "WHERE upload_fk = $$uploadIdPos;";
391 $this->
dbManager->getSingleRow($SQL, $parms,
392 __METHOD__ .
"updateReportInfoData");
394 if (@$_POST[
'markGlobal']) {
395 $upload = $this->uploadDao->getUpload($uploadId);
396 $uploadName = $upload->getFilename();
397 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
400 $conflictStrategyId =
"global";
402 $deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
405 $text = _(
"Your jobs have been added to job queue.");
406 $linkText = _(
"View Jobs");
407 $this->vars[
'message'] =
"$schedulerMsg" .
"$text <a href=\"$url\">$linkText</a>";
411 $this->vars[
'typemap'] = [];
412 foreach (ComponentType::TYPE_MAP as $key => $name) {
413 if ($key == ComponentType::PACKAGEURL) {
416 $this->vars[
'typemap'][] = [
'key' => $key,
'name' => $name];
420 public function getTemplateName()
422 return "ui-report-conf.html.twig";
433 var reportTabCookie = 'stickyReportTab';
435 $(document).ready(function() {
436 $(\"#confTabs\").tabs({
437 active: ($.cookie(reportTabCookie) || 0),
438 activate: function(e, ui){
439 // Get active tab index and update cookie
440 var idString = $(e.currentTarget).attr('id');
441 idString = parseInt(idString.slice(-1)) - 1;
442 $.cookie(reportTabCookie, idString);
445 $(\"input[name='dependencySourceBinary']\").change(function(){
446 var val = $(\"input[name='dependencySourceBinary']:checked\").val();
447 if (val == 'noDependency') {
448 $('#dependencyBinarySource').hide();
449 $('#dependencyBinarySource').val('');
451 $('#dependencyBinarySource').css('display', 'block');
454 $(\"input[name='exportRestriction']\").change(function(){
455 var val = $(\"input[name='exportRestriction']:checked\").val();
456 if (val == 'noExportRestriction') {
457 $('#exportRestrictionText').hide();
458 $('#exportRestrictionText').val('');
460 $('#exportRestrictionText').css('display', 'block');
463 $(\"input[name='restrictionForUse']\").change(function(){
464 var val = $(\"input[name='restrictionForUse']:checked\").val();
465 if (val == 'noRestriction') {
466 $('#copyrightRestrictionText').hide();
467 $('#copyrightRestrictionText').val('');
469 $('#copyrightRestrictionText').css('display', 'block');
473 $('#osselotExportCheckbox').change(function() {
474 if ($(this).is(':checked')) {
475 $('#spdxLicenseCommentCheckbox').prop('checked', true);
484 $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($uploadId, $groupId)
get all the obgligations for cleared licenses
createScriptBlock()
Create Script block for conf.
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:
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
fo_dbManager * dbManager
fo_dbManager object