56 private $mapDBColumns = array(
57 "reviewedBy" =>
"ri_reviewed",
58 "department" =>
"ri_department",
59 "reportRel" =>
"ri_report_rel",
60 "community" =>
"ri_community",
61 "component" =>
"ri_component",
62 "version" =>
"ri_version",
63 "relDate" =>
"ri_release_date",
64 "sw360Link" =>
"ri_sw360_link",
65 "footerNote" =>
"ri_footer",
66 "generalAssesment" =>
"ri_general_assesment",
67 "gaAdditional" =>
"ri_ga_additional",
68 "gaRisk" =>
"ri_ga_risk" 74 private $checkBoxListUR = array(
80 "noExportRestriction",
89 private $checkBoxListSPDX = array(
95 function __construct()
97 $this->Name =
"report_conf";
98 $this->Title = _(
"Report Configuration");
99 $this->Dependency = array(
"browse");
101 $this->LoginFlag = 0;
102 parent::__construct();
103 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
104 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
105 $this->userDao = $GLOBALS[
'container']->get(
'dao.user');
106 $this->clearingDao = $GLOBALS[
'container']->get(
'dao.clearing');
107 $this->licenseDao = $GLOBALS[
'container']->get(
'dao.license');
115 $tooltipText = _(
"Report Configuration");
116 menu_insert(
"Browse-Pfile::Conf",5,$this->Name,$tooltipText);
119 $URI = $this->Name . $Parm;
129 menu_insert(
"View-Meta::{$menuText}", $menuPosition);
133 $tooltipText = _(
"Report Configuration");
136 menu_insert(
"View::{$menuText}", $menuPosition, $URI, $tooltipText);
139 menu_insert(
"View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
141 menu_insert(
"Browse::Conf", -3, $URI, $tooltipText);
154 $row = $this->uploadDao->getReportInfo($uploadId);
155 foreach ($this->mapDBColumns as $key => $value) {
156 $vars[$key] = $row[$value];
159 if (!empty($row[
'ri_ga_checkbox_selection'])) {
160 $listURCheckbox = explode(
',', $row[
'ri_ga_checkbox_selection']);
161 foreach ($this->checkBoxListUR as $key => $value) {
162 $vars[$value] = $listURCheckbox[$key];
166 if (!empty($row[
'ri_spdx_selection'])) {
167 $listSPDXCheckbox = explode(
',', $row[
'ri_spdx_selection']);
168 foreach ($this->checkBoxListSPDX as $key => $value) {
169 $vars[$value] = $listSPDXCheckbox[$key];
174 $excludedObligations = array();
175 $excludedObligations = (array) json_decode($row[
'ri_excluded_obligations'],
true);
177 $tableRows .=
'<tr><td style="width:35%">'.$obTopic.
'</td>';
178 $tableRows .=
'<td><textarea readonly="readonly" style="overflow:auto;width:98%;height:80px;">'.
179 $obData[
'text'].
'</textarea></td><td>';
180 foreach ($obData[
'license'] as $value) {
181 if (!empty($excludedObligations[$obTopic]) && in_array($value, $excludedObligations[$obTopic])) {
182 $tableRows .=
'<input type="checkbox" name="obLicenses['.$obTopic.
'][]" value="'.$value.
'" checked> '.$value.
'<br />';
184 $tableRows .=
'<input type="checkbox" name="obLicenses['.$obTopic.
'][]" value="'.$value.
'"> '.$value.
'<br />';
187 $tableRows .=
'</td></tr>';
189 $vars[
'tableRows'] = $tableRows;
203 $allClearedLicenses = array();
204 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
205 $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
206 $allClearingDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId);
208 foreach ($allClearingDecisions as $clearingDecisions) {
209 if ($clearingDecisions->getType() == DecisionTypes::IRRELEVANT) {
212 foreach ($clearingDecisions->getClearingLicenses() as $eachClearingLicense) {
213 if ($eachClearingLicense->isRemoved()) {
216 $getLicenseId = $eachClearingLicense->getLicenseId();
217 $allClearedLicenses[] = $licenseMap->getProjectedId($getLicenseId);
220 $obligationsForLicenses = $this->licenseDao->getLicenseObligations($allClearedLicenses,
'obligation_map') ?: array();
221 $obligationsForLicenseCandidates = $this->licenseDao->getLicenseObligations($allClearedLicenses,
'obligation_candidate_map') ?: array();
222 $allObligations = array_merge($obligationsForLicenses, $obligationsForLicenseCandidates);
223 $groupedObligations = array();
224 foreach ($allObligations as $obligations) {
225 $groupBy = $obligations[
'ob_topic'];
226 if (array_key_exists($groupBy, $groupedObligations)) {
227 $currentLicenses = &$groupedObligations[$groupBy][
'license'];
228 if (!in_array($obligations[
'rf_shortname'], $currentLicenses)) {
229 $currentLicenses[] = $obligations[
'rf_shortname'];
232 $groupedObligations[$groupBy] = array(
233 "topic" => $obligations[
'ob_topic'],
234 "text" => $obligations[
'ob_text'],
235 "license" => array($obligations[
'rf_shortname'])
239 return $groupedObligations;
248 foreach ($checkBoxListParams as $checkBoxListParam) {
251 $cbList[] =
"unchecked";
253 $cbList[] =
"checked";
256 $cbSelectionList = implode(
",", $cbList);
258 return $cbSelectionList;
264 $groupId = Auth::getGroupId();
265 $userId = Auth::getUserId();
266 if (!$this->uploadDao->isAccessible($uploadId, $groupId)) {
271 $this->vars[
'micromenu'] =
Dir2Browse(
"browse", $itemId, NULL, $showBox=0,
"View-Meta");
272 $this->vars[
'globalClearingAvailable'] = Auth::isClearingAdmin();
276 if (isset($submitReportConf)) {
278 $obLicenses = @$_POST[
"obLicenses"];
281 foreach ($this->mapDBColumns as $key => $value) {
282 $columns .= $value.
" = $".$i.
", ";
287 $checkBoxUrPos = count($parms);
289 $checkBoxSpdxPos = count($parms);
290 $parms[] = json_encode($obLicenses);
291 $excludeObligationPos = count($parms);
292 $parms[] = $uploadId;
293 $uploadIdPos = count($parms);
295 $SQL =
"UPDATE report_info SET $columns" .
296 "ri_ga_checkbox_selection = $$checkBoxUrPos, " .
297 "ri_spdx_selection = $$checkBoxSpdxPos, " .
298 "ri_excluded_obligations = $$excludeObligationPos" .
299 "WHERE upload_fk = $$uploadIdPos;";
300 $this->
dbManager->getSingleRow($SQL, $parms,
301 __METHOD__ .
"updateReportInfoData");
303 if (@$_POST[
'markGlobal']) {
304 $upload = $this->uploadDao->getUpload($uploadId);
305 $uploadName = $upload->getFilename();
306 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
309 $conflictStrategyId =
"global";
311 $deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
314 $text = _(
"Your jobs have been added to job queue.");
315 $linkText = _(
"View Jobs");
316 $this->vars[
'message'] =
"$schedulerMsg" .
"$text <a href=\"$url\">$linkText</a>";
322 public function getTemplateName()
324 return "ui-report-conf.html.twig";
335 var reportTabCookie = 'stickyReportTab'; 337 $(document).ready(function() { 338 $(\"#confTabs\").tabs({ 339 active: ($.cookie(reportTabCookie) || 0), 340 activate: function(e, ui){ 341 // Get active tab index and update cookie 342 var idString = $(e.currentTarget).attr('id'); 343 idString = parseInt(idString.slice(-1)) - 1; 344 $.cookie(reportTabCookie, idString); 353 $NewPlugin->Initialize();
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.
GetRunnableJobList()
Get runnable job list, the process is below:
Traceback_uri()
Get the URI without query to this location.
getCheckBoxSelectionList($checkBoxListParams)
getAllObligationsForGivenUploadId($uploadId, $groupId)
get all the obgligations for cleared licenses
createScriptBlock()
Create Script block for conf.
RegisterMenus()
Customize submenus.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
Wrapper class for license map.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
fo_dbManager * dbManager
fo_dbManager object
This is the Plugin class. All plugins should:
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
Output()
This function is called when user output is requested. This function is responsible for content...
allReportConfiguration($uploadId, $groupId)
list all the options for Report Configuration