46 private $mapDBColumns = array(
47 "reviewedBy" =>
"ri_reviewed",
48 "department" =>
"ri_department",
49 "reportRel" =>
"ri_report_rel",
50 "community" =>
"ri_community",
51 "component" =>
"ri_component",
52 "version" =>
"ri_version",
53 "relDate" =>
"ri_release_date",
54 "sw360Link" =>
"ri_sw360_link",
55 "componentType" =>
"ri_component_type",
56 "componentId" =>
"ri_component_id",
57 "footerNote" =>
"ri_footer",
58 "generalAssesment" =>
"ri_general_assesment",
59 "gaAdditional" =>
"ri_ga_additional",
60 "gaRisk" =>
"ri_ga_risk",
61 "dependencyBinarySource" =>
"ri_depnotes",
62 "exportRestrictionText" =>
"ri_exportnotes",
63 "copyrightRestrictionText" =>
"ri_copyrightnotes"
69 private $radioListUR = array(
70 "nonCritical" =>
"critical",
71 "critical" =>
"critical",
72 "noDependency" =>
"dependencySourceBinary",
73 "dependencySource" =>
"dependencySourceBinary",
74 "dependencyBinary" =>
"dependencySourceBinary",
75 "noExportRestriction" =>
"exportRestriction",
76 "exportRestriction" =>
"exportRestriction",
77 "noRestriction" =>
"restrictionForUse",
78 "restrictionForUse" =>
"restrictionForUse"
84 private $checkBoxListSPDX = array(
85 "spdxLicenseComment" =>
"spdxLicenseComment",
86 "ignoreFilesWOInfo" =>
"ignoreFilesWOInfo"
92 $this->Name =
"report_conf";
93 $this->Title = _(
"Report Configuration");
94 $this->Dependency = array(
"browse");
97 parent::__construct();
98 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
99 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
100 $this->userDao = $GLOBALS[
'container']->get(
'dao.user');
101 $this->clearingDao = $GLOBALS[
'container']->get(
'dao.clearing');
102 $this->licenseDao = $GLOBALS[
'container']->get(
'dao.license');
110 $tooltipText = _(
"Report Configuration");
111 menu_insert(
"Browse-Pfile::Conf",5,$this->Name,$tooltipText);
114 $URI = $this->Name . $Parm;
124 menu_insert(
"View-Meta::{$menuText}", $menuPosition);
128 $tooltipText = _(
"Report Configuration");
131 menu_insert(
"View::{$menuText}", $menuPosition, $URI, $tooltipText);
134 menu_insert(
"View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
136 menu_insert(
"Browse::Conf", -3, $URI, $tooltipText);
149 $row = $this->uploadDao->getReportInfo($uploadId);
150 foreach ($this->mapDBColumns as $key => $value) {
151 $vars[$key] = $row[$value];
153 $textAreaNoneStyle =
' style="display:none;overflow:auto;width:98%;height:80px;"';
154 $textAreaStyle =
' style="overflow:auto;width:98%;height:80px;"';
155 $vars[
'styleDependencyTA'] = $vars[
'styleExportTA'] = $vars[
'styleRestrictionTA'] = $textAreaStyle;
156 if ($row[
'ri_depnotes'] ==
'NA' || empty($row[
'ri_depnotes'])) {
157 $vars[
'styleDependencyTA'] = $textAreaNoneStyle;
160 if ($row[
'ri_exportnotes'] ==
'NA' || empty($row[
'ri_exportnotes'])) {
161 $vars[
'styleExportTA'] = $textAreaNoneStyle;
164 if ($row[
'ri_copyrightnotes'] ==
'NA' || empty($row[
'ri_copyrightnotes'])) {
165 $vars[
'styleRestrictionTA'] = $textAreaNoneStyle;
168 if (!empty($row[
'ri_ga_checkbox_selection'])) {
169 $listURCheckbox = explode(
',', $row[
'ri_ga_checkbox_selection']);
170 foreach (array_keys($this->radioListUR) as $key => $value) {
171 $vars[$value] = $listURCheckbox[$key];
175 if (!empty($row[
'ri_spdx_selection'])) {
176 $listSPDXCheckbox = explode(
',', $row[
'ri_spdx_selection']);
177 foreach (array_keys($this->checkBoxListSPDX) as $key => $value) {
178 $vars[$value] = $listSPDXCheckbox[$key];
183 $excludedObligations = array();
184 $excludedObligations = (array) json_decode($row[
'ri_excluded_obligations'],
true);
186 $tableRows .=
'<tr><td style="width:35%">'.$obTopic.
'</td>';
187 $tableRows .=
'<td><textarea readonly="readonly" style="overflow:auto;width:98%;height:80px;">'.
188 $obData[
'text'].
'</textarea></td><td>';
189 foreach ($obData[
'license'] as $value) {
190 if (!empty($excludedObligations[$obTopic]) && in_array($value, $excludedObligations[$obTopic])) {
191 $tableRows .=
'<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).
'][]" value="'.$value.
'" checked> '.$value.
'<br />';
193 $tableRows .=
'<input class="browse-upload-checkbox view-license-rc-size" type="checkbox" name="obLicenses['.urlencode($obTopic).
'][]" value="'.$value.
'"> '.$value.
'<br />';
196 $tableRows .=
'</td></tr>';
198 $tableRowsUnifiedReport =
"";
199 $unifiedColumns = array();
200 if (!empty($row[
'ri_unifiedcolumns'])) {
201 $unifiedColumns = (array) json_decode($row[
'ri_unifiedcolumns'],
true);
203 $unifiedColumns = UploadDao::UNIFIED_REPORT_HEADINGS;
205 foreach ($unifiedColumns as $name => $unifiedReportColumns) {
206 foreach ($unifiedReportColumns as $columnName => $isenabled) {
207 $tableRowsUnifiedReport .=
'<tr>';
208 $tableRowsUnifiedReport .=
'<td><input class="form-control" type="text" style="width:95%" name="'.$name.
'[]" value="'.$columnName.
'"></td>';
211 $checked =
'checked';
213 $tableRowsUnifiedReport .=
'<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.
'[]" '.$checked.
'></td>';
214 $tableRowsUnifiedReport .=
'</tr>';
218 $tableRowsClixmlReport =
"";
219 $clixmlColumns = array();
220 if (!empty($row[
'ri_clixmlcolumns'])) {
221 $clixmlColumns = (array) json_decode($row[
'ri_clixmlcolumns'],
true);
223 $clixmlColumns = UploadDao::CLIXML_REPORT_HEADINGS;
225 foreach ($clixmlColumns as $name => $clixmlReportColumns) {
226 foreach ($clixmlReportColumns as $columnName => $isenabled) {
227 $tableRowsClixmlReport .=
'<tr>';
228 $tableRowsClixmlReport .=
'<td><input class="form-control" type="text" style="width:95%" name="'.$name.
'[]" value="'.$columnName.
'" readonly></td>';
231 $checked =
'checked';
233 $tableRowsClixmlReport .=
'<td style="vertical-align:middle"><input class="browse-upload-checkbox view-license-rc-size" type="checkbox" style="width:95%" name="'.$name.
'[]" '.$checked.
'></td>';
234 $tableRowsClixmlReport .=
'</tr>';
238 if (!empty($row[
'ri_globaldecision'])) {
239 $vars[
'applyGlobal'] =
"checked";
241 $vars[
'tableRows'] = $tableRows;
242 $vars[
'tableRowsUnifiedReport'] = $tableRowsUnifiedReport;
243 $vars[
'tableRowsClixmlReport'] = $tableRowsClixmlReport;
257 $allClearedLicenses = array();
258 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
259 $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
260 $allClearingDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId);
262 foreach ($allClearingDecisions as $clearingDecisions) {
263 if ($clearingDecisions->getType() == DecisionTypes::IRRELEVANT) {
266 foreach ($clearingDecisions->getClearingLicenses() as $eachClearingLicense) {
267 if ($eachClearingLicense->isRemoved()) {
270 $getLicenseId = $eachClearingLicense->getLicenseId();
271 $allClearedLicenses[] = $licenseMap->getProjectedId($getLicenseId);
274 $obligationsForLicenses = $this->licenseDao->getLicenseObligations($allClearedLicenses) ?: array();
275 $obligationsForLicenseCandidates = $this->licenseDao->getLicenseObligations($allClearedLicenses,
true) ?: array();
276 $allObligations = array_merge($obligationsForLicenses, $obligationsForLicenseCandidates);
277 $groupedObligations = array();
278 foreach ($allObligations as $obligations) {
279 $groupBy = $obligations[
'ob_topic'];
280 if (array_key_exists($groupBy, $groupedObligations)) {
281 $currentLicenses = &$groupedObligations[$groupBy][
'license'];
282 if (!in_array($obligations[
'rf_shortname'], $currentLicenses)) {
283 $currentLicenses[] = $obligations[
'rf_shortname'];
286 $groupedObligations[$groupBy] = array(
287 "topic" => $obligations[
'ob_topic'],
288 "text" => $obligations[
'ob_text'],
289 "license" => array($obligations[
'rf_shortname'])
293 return $groupedObligations;
302 foreach ($listParams as $listkey => $listValue) {
304 if ($ret != $listkey) {
305 $cbList[] =
"unchecked";
307 $cbList[] =
"checked";
310 $cbSelectionList = implode(
",", $cbList);
312 return $cbSelectionList;
318 $groupId = Auth::getGroupId();
319 $userId = Auth::getUserId();
320 if (!$this->uploadDao->isAccessible($uploadId, $groupId)) {
325 $this->vars[
'micromenu'] =
Dir2Browse(
"browse", $itemId, NULL, $showBox=0,
"View-Meta");
326 $this->vars[
'globalClearingAvailable'] = Auth::isClearingAdmin();
330 if (isset($submitReportConf)) {
331 $applyGlobal = @$_POST[
"applyGlobal"];
332 $applyGlobal = !empty($applyGlobal) ? 1 : 0;
334 $obLicensesEncoded = @$_POST[
"obLicenses"];
335 $obLicensesEncoded = !empty($obLicensesEncoded) ? $obLicensesEncoded : array();
336 $obLicenses = array();
337 array_walk($obLicensesEncoded,
338 function (&$licArray, $obTopic) use (&$obLicenses) {
339 $obLicenses[urldecode($obTopic)] = $licArray;
344 foreach ($this->mapDBColumns as $key => $value) {
345 $columns .= $value.
" = $".$i.
", ";
351 $unifiedReportColumnsForJson = array();
352 foreach (UploadDao::UNIFIED_REPORT_HEADINGS as $columnName => $columnValue) {
353 $columnResult = @$_POST[$columnName];
354 $unifiedReportColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] :
null);
356 $clixmlColumnsForJson = array();
357 foreach (UploadDao::CLIXML_REPORT_HEADINGS as $columnName => $columnValue) {
358 $columnResult = @$_POST[$columnName];
359 $clixmlColumnsForJson[$columnName] = array($columnResult[0] => isset($columnResult[1]) ? $columnResult[1] :
null);
361 $checkBoxUrPos = count($parms);
363 $checkBoxSpdxPos = count($parms);
364 $parms[] = json_encode($obLicenses);
365 $excludeObligationPos = count($parms);
366 $parms[] = json_encode($unifiedReportColumnsForJson);
367 $unifiedColumnsPos = count($parms);
368 $parms[] = json_encode($clixmlColumnsForJson);
369 $clixmlColumnsPos = count($parms);
370 $parms[] = $applyGlobal;
371 $applyGlobalPos = count($parms);
372 $parms[] = $uploadId;
373 $uploadIdPos = count($parms);
375 $SQL =
"UPDATE report_info SET $columns" .
376 "ri_ga_checkbox_selection = $$checkBoxUrPos, " .
377 "ri_spdx_selection = $$checkBoxSpdxPos, " .
378 "ri_excluded_obligations = $$excludeObligationPos, " .
379 "ri_unifiedcolumns = $$unifiedColumnsPos, " .
380 "ri_clixmlcolumns = $$clixmlColumnsPos, " .
381 "ri_globaldecision = $$applyGlobalPos " .
382 "WHERE upload_fk = $$uploadIdPos;";
383 $this->
dbManager->getSingleRow($SQL, $parms,
384 __METHOD__ .
"updateReportInfoData");
386 if (@$_POST[
'markGlobal']) {
387 $upload = $this->uploadDao->getUpload($uploadId);
388 $uploadName = $upload->getFilename();
389 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
392 $conflictStrategyId =
"global";
394 $deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
397 $text = _(
"Your jobs have been added to job queue.");
398 $linkText = _(
"View Jobs");
399 $this->vars[
'message'] =
"$schedulerMsg" .
"$text <a href=\"$url\">$linkText</a>";
403 $this->vars[
'typemap'] = [];
404 foreach (ComponentType::TYPE_MAP as $key => $name) {
405 if ($key == ComponentType::PACKAGEURL) {
408 $this->vars[
'typemap'][] = [
'key' => $key,
'name' => $name];
412 public function getTemplateName()
414 return "ui-report-conf.html.twig";
425 var reportTabCookie = 'stickyReportTab';
427 $(document).ready(function() {
428 $(\"#confTabs\").tabs({
429 active: ($.cookie(reportTabCookie) || 0),
430 activate: function(e, ui){
431 // Get active tab index and update cookie
432 var idString = $(e.currentTarget).attr('id');
433 idString = parseInt(idString.slice(-1)) - 1;
434 $.cookie(reportTabCookie, idString);
437 $(\"input[name='dependencySourceBinary']\").change(function(){
438 var val = $(\"input[name='dependencySourceBinary']:checked\").val();
439 if (val == 'noDependency') {
440 $('#dependencyBinarySource').hide();
441 $('#dependencyBinarySource').val('');
443 $('#dependencyBinarySource').css('display', 'block');
446 $(\"input[name='exportRestriction']\").change(function(){
447 var val = $(\"input[name='exportRestriction']:checked\").val();
448 if (val == 'noExportRestriction') {
449 $('#exportRestrictionText').hide();
450 $('#exportRestrictionText').val('');
452 $('#exportRestrictionText').css('display', 'block');
455 $(\"input[name='restrictionForUse']\").change(function(){
456 var val = $(\"input[name='restrictionForUse']:checked\").val();
457 if (val == 'noRestriction') {
458 $('#copyrightRestrictionText').hide();
459 $('#copyrightRestrictionText').val('');
461 $('#copyrightRestrictionText').css('display', 'block');
470 $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