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"
93 $this->Name =
"report_conf";
94 $this->Title = _(
"Report Configuration");
95 $this->Dependency = array(
"browse");
98 parent::__construct();
99 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
100 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
101 $this->userDao = $GLOBALS[
'container']->get(
'dao.user');
102 $this->clearingDao = $GLOBALS[
'container']->get(
'dao.clearing');
103 $this->licenseDao = $GLOBALS[
'container']->get(
'dao.license');
111 $tooltipText = _(
"Report Configuration");
112 menu_insert(
"Browse-Pfile::Conf",5,$this->Name,$tooltipText);
115 $URI = $this->Name . $Parm;
125 menu_insert(
"View-Meta::{$menuText}", $menuPosition);
129 $tooltipText = _(
"Report Configuration");
132 menu_insert(
"View::{$menuText}", $menuPosition, $URI, $tooltipText);
135 menu_insert(
"View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
137 menu_insert(
"Browse::Conf", -3, $URI, $tooltipText);
150 $row = $this->uploadDao->getReportInfo($uploadId);
151 foreach ($this->mapDBColumns as $key => $value) {
152 $vars[$key] = $row[$value];
154 $textAreaNoneStyle =
' style="display:none;overflow:auto;width:98%;height:80px;"';
155 $textAreaStyle =
' style="overflow:auto;width:98%;height:80px;"';
156 $vars[
'styleDependencyTA'] = $vars[
'styleExportTA'] = $vars[
'styleRestrictionTA'] = $textAreaStyle;
157 if ($row[
'ri_depnotes'] ==
'NA' || empty($row[
'ri_depnotes'])) {
158 $vars[
'styleDependencyTA'] = $textAreaNoneStyle;
161 if ($row[
'ri_exportnotes'] ==
'NA' || empty($row[
'ri_exportnotes'])) {
162 $vars[
'styleExportTA'] = $textAreaNoneStyle;
165 if ($row[
'ri_copyrightnotes'] ==
'NA' || empty($row[
'ri_copyrightnotes'])) {
166 $vars[
'styleRestrictionTA'] = $textAreaNoneStyle;
169 if (!empty($row[
'ri_ga_checkbox_selection'])) {
170 $listURCheckbox = explode(
',', $row[
'ri_ga_checkbox_selection']);
171 foreach (array_keys($this->radioListUR) as $key => $value) {
172 $vars[$value] = $listURCheckbox[$key];
176 if (!empty($row[
'ri_spdx_selection'])) {
177 $listSPDXCheckbox = explode(
',', $row[
'ri_spdx_selection']);
178 foreach (array_keys($this->checkBoxListSPDX) as $key => $value) {
179 $vars[$value] = $listSPDXCheckbox[$key];
184 $excludedObligations = array();
185 $excludedObligations = (array) json_decode($row[
'ri_excluded_obligations'],
true);
187 $tableRows .=
'<tr><td style="width:35%">'.$obTopic.
'</td>';
188 $tableRows .=
'<td><textarea readonly="readonly" style="overflow:auto;width:98%;height:80px;">'.
189 $obData[
'text'].
'</textarea></td><td>';
190 foreach ($obData[
'license'] as $value) {
191 if (!empty($excludedObligations[$obTopic]) && in_array($value, $excludedObligations[$obTopic])) {
192 $tableRows .=
'<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).
'][]" value="'.$value.
'" checked> '.$value.
'<br />';
194 $tableRows .=
'<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).
'][]" value="'.$value.
'"> '.$value.
'<br />';
197 $tableRows .=
'</td></tr>';
199 $tableRowsUnifiedReport =
"";
200 $unifiedColumns = array();
201 if (!empty($row[
'ri_unifiedcolumns'])) {
202 $unifiedColumns = (array) json_decode($row[
'ri_unifiedcolumns'],
true);
204 $unifiedColumns = UploadDao::UNIFIED_REPORT_HEADINGS;
206 foreach ($unifiedColumns as $name => $unifiedReportColumns) {
207 foreach ($unifiedReportColumns as $columnName => $isenabled) {
208 $tableRowsUnifiedReport .=
'<tr>';
209 $tableRowsUnifiedReport .=
'<td><input class="form-control" type="text" style="width:95%" name="'.$name.
'[]" value="'.$columnName.
'"></td>';
212 $checked =
'checked';
214 $tableRowsUnifiedReport .=
'<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.
'[]" '.$checked.
'></td>';
215 $tableRowsUnifiedReport .=
'</tr>';
219 $tableRowsClixmlReport =
"";
220 $clixmlColumns = array();
221 if (!empty($row[
'ri_clixmlcolumns'])) {
222 $clixmlColumns = (array) json_decode($row[
'ri_clixmlcolumns'],
true);
224 $clixmlColumns = UploadDao::CLIXML_REPORT_HEADINGS;
226 foreach ($clixmlColumns as $name => $clixmlReportColumns) {
227 foreach ($clixmlReportColumns as $columnName => $isenabled) {
228 $tableRowsClixmlReport .=
'<tr>';
229 $tableRowsClixmlReport .=
'<td><input class="form-control" type="text" style="width:95%" name="'.$name.
'[]" value="'.$columnName.
'" readonly></td>';
232 $checked =
'checked';
234 $tableRowsClixmlReport .=
'<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.
'[]" '.$checked.
'></td>';
235 $tableRowsClixmlReport .=
'</tr>';
239 if (!empty($row[
'ri_globaldecision'])) {
240 $vars[
'applyGlobal'] =
"checked";
242 $vars[
'tableRows'] = $tableRows;
243 $vars[
'tableRowsUnifiedReport'] = $tableRowsUnifiedReport;
244 $vars[
'tableRowsClixmlReport'] = $tableRowsClixmlReport;
258 $allClearedLicenses = array();
259 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
260 $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
261 $allClearingDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId);
263 foreach ($allClearingDecisions as $clearingDecisions) {
264 if ($clearingDecisions->getType() == DecisionTypes::IRRELEVANT) {
267 foreach ($clearingDecisions->getClearingLicenses() as $eachClearingLicense) {
268 if ($eachClearingLicense->isRemoved()) {
271 $getLicenseId = $eachClearingLicense->getLicenseId();
272 $allClearedLicenses[] = $licenseMap->getProjectedId($getLicenseId);
275 $obligationsForLicenses = $this->licenseDao->getLicenseObligations($allClearedLicenses) ?: array();
276 $obligationsForLicenseCandidates = $this->licenseDao->getLicenseObligations($allClearedLicenses,
true) ?: array();
277 $allObligations = array_merge($obligationsForLicenses, $obligationsForLicenseCandidates);
278 $groupedObligations = array();
279 foreach ($allObligations as $obligations) {
280 $groupBy = $obligations[
'ob_topic'];
281 $licenseName = LicenseRef::convertToSpdxId($obligations[
'rf_shortname'],
282 $obligations[
'rf_spdx_id']);
283 if (array_key_exists($groupBy, $groupedObligations)) {
284 $currentLicenses = &$groupedObligations[$groupBy][
'license'];
285 if (!in_array($licenseName, $currentLicenses)) {
286 $currentLicenses[] = $licenseName;
289 $groupedObligations[$groupBy] = array(
290 "topic" => $obligations[
'ob_topic'],
291 "text" => $obligations[
'ob_text'],
292 "license" => array($licenseName)
296 return $groupedObligations;
305 foreach ($listParams as $listkey => $listValue) {
307 if ($ret != $listkey) {
308 $cbList[] =
"unchecked";
310 $cbList[] =
"checked";
313 $cbSelectionList = implode(
",", $cbList);
315 return $cbSelectionList;
321 $groupId = Auth::getGroupId();
322 $userId = Auth::getUserId();
323 if (!$this->uploadDao->isAccessible($uploadId, $groupId)) {
328 $this->vars[
'micromenu'] =
Dir2Browse(
"browse", $itemId, NULL, $showBox=0,
"View-Meta");
329 $this->vars[
'globalClearingAvailable'] = Auth::isClearingAdmin();
333 if (isset($submitReportConf)) {
334 $applyGlobal = @$_POST[
"applyGlobal"];
335 $applyGlobal = !empty($applyGlobal) ? 1 : 0;
337 $obLicensesEncoded = @$_POST[
"obLicenses"];
338 $obLicensesEncoded = !empty($obLicensesEncoded) ? $obLicensesEncoded : array();
339 $obLicenses = array();
340 array_walk($obLicensesEncoded,
341 function (&$licArray, $obTopic) use (&$obLicenses) {
342 $obLicenses[urldecode($obTopic)] = $licArray;
347 foreach ($this->mapDBColumns as $key => $value) {
348 $columns .= $value.
" = $".$i.
", ";
354 $unifiedReportColumnsForJson = array();
355 foreach (UploadDao::UNIFIED_REPORT_HEADINGS as $columnName => $columnValue) {
356 $columnResult = @$_POST[$columnName];
357 $unifiedReportColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] :
null);
359 $clixmlColumnsForJson = array();
360 foreach (UploadDao::CLIXML_REPORT_HEADINGS as $columnName => $columnValue) {
361 $columnResult = @$_POST[$columnName];
362 $clixmlColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] :
null);
364 $checkBoxUrPos = count($parms);
366 $checkBoxSpdxPos = count($parms);
367 $parms[] = json_encode($obLicenses);
368 $excludeObligationPos = count($parms);
369 $parms[] = json_encode($unifiedReportColumnsForJson);
370 $unifiedColumnsPos = count($parms);
371 $parms[] = json_encode($clixmlColumnsForJson);
372 $clixmlColumnsPos = count($parms);
373 $parms[] = $applyGlobal;
374 $applyGlobalPos = count($parms);
375 $parms[] = $uploadId;
376 $uploadIdPos = count($parms);
378 $SQL =
"UPDATE report_info SET $columns" .
379 "ri_ga_checkbox_selection = $$checkBoxUrPos, " .
380 "ri_spdx_selection = $$checkBoxSpdxPos, " .
381 "ri_excluded_obligations = $$excludeObligationPos, " .
382 "ri_unifiedcolumns = $$unifiedColumnsPos, " .
383 "ri_clixmlcolumns = $$clixmlColumnsPos, " .
384 "ri_globaldecision = $$applyGlobalPos " .
385 "WHERE upload_fk = $$uploadIdPos;";
386 $this->
dbManager->getSingleRow($SQL, $parms,
387 __METHOD__ .
"updateReportInfoData");
389 if (@$_POST[
'markGlobal']) {
390 $upload = $this->uploadDao->getUpload($uploadId);
391 $uploadName = $upload->getFilename();
392 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
395 $conflictStrategyId =
"global";
397 $deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
400 $text = _(
"Your jobs have been added to job queue.");
401 $linkText = _(
"View Jobs");
402 $this->vars[
'message'] =
"$schedulerMsg" .
"$text <a href=\"$url\">$linkText</a>";
406 $this->vars[
'typemap'] = [];
407 foreach (ComponentType::TYPE_MAP as $key => $name) {
408 if ($key == ComponentType::PACKAGEURL) {
411 $this->vars[
'typemap'][] = [
'key' => $key,
'name' => $name];
415 public function getTemplateName()
417 return "ui-report-conf.html.twig";
428 var reportTabCookie = 'stickyReportTab';
430 $(document).ready(function() {
431 $(\"#confTabs\").tabs({
432 active: ($.cookie(reportTabCookie) || 0),
433 activate: function(e, ui){
434 // Get active tab index and update cookie
435 var idString = $(e.currentTarget).attr('id');
436 idString = parseInt(idString.slice(-1)) - 1;
437 $.cookie(reportTabCookie, idString);
440 $(\"input[name='dependencySourceBinary']\").change(function(){
441 var val = $(\"input[name='dependencySourceBinary']:checked\").val();
442 if (val == 'noDependency') {
443 $('#dependencyBinarySource').hide();
444 $('#dependencyBinarySource').val('');
446 $('#dependencyBinarySource').css('display', 'block');
449 $(\"input[name='exportRestriction']\").change(function(){
450 var val = $(\"input[name='exportRestriction']:checked\").val();
451 if (val == 'noExportRestriction') {
452 $('#exportRestrictionText').hide();
453 $('#exportRestrictionText').val('');
455 $('#exportRestrictionText').css('display', 'block');
458 $(\"input[name='restrictionForUse']\").change(function(){
459 var val = $(\"input[name='restrictionForUse']:checked\").val();
460 if (val == 'noRestriction') {
461 $('#copyrightRestrictionText').hide();
462 $('#copyrightRestrictionText').val('');
464 $('#copyrightRestrictionText').css('display', 'block');
473 $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