FOSSology  4.4.0
Open Source License Compliance by Open Source Software
admin-license-file.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008-2014 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2015-2018 Siemens AG
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 use Composer\Spdx\SpdxLicenses;
16 use Symfony\Component\HttpFoundation\Response;
17 
18 define("TITLE_ADMIN_LICENSE_FILE", _("License Administration"));
19 
21 {
23  private $dbManager;
24 
26  private $licenseDao;
27 
28  function __construct()
29  {
30  $this->Name = "admin_license";
31  $this->Title = TITLE_ADMIN_LICENSE_FILE;
32  $this->MenuList = "Admin::License Admin";
33  $this->DBaccess = PLUGIN_DB_ADMIN;
34  $this->vars = array();
35  $this->obligationSelectorName = "assocObligations";
36  $this->obligationSelectorId = "assocObligations";
37  parent::__construct();
38 
39  $this->dbManager = $GLOBALS['container']->get('db.manager');
40  $this->licenseDao = $GLOBALS['container']->get('dao.license');
41  }
42 
46  function RegisterMenus()
47  {
48  if ($this->State != PLUGIN_STATE_READY) {
49  return(0);
50  }
51 
52  $URL = $this->Name."&add=y";
53  $text = _("Add new license");
54  menu_insert("Main::".$this->MenuList."::Add License",0, $URL, $text);
55  $URL = $this->Name;
56  $text = _("Select license family");
57  menu_insert("Main::".$this->MenuList."::Select License",0, $URL, $text);
58  }
59 
60  public function Output()
61  {
62  $V = "";
63  $errorstr = "License not added";
64 
65  // update the db
66  if (@$_POST["updateit"]) {
67  $resultstr = $this->Updatedb($_POST);
68  $this->vars['message'] = $resultstr;
69  if (strstr($resultstr, $errorstr)) {
70  return $this->Updatefm(0);
71  } else {
72  return $this->Inputfm();
73  }
74  }
75 
76  if (@$_REQUEST['add'] == 'y') {
77  return $this->Updatefm(0);
78  }
79 
80  // Add new rec to db
81  if (@$_POST["addit"]) {
82  $resultstr = $this->Adddb();
83  $this->vars['message'] = $resultstr;
84  if (strstr($resultstr, $errorstr)) {
85  return $this->Updatefm(0);
86  } else {
87  return $this->Inputfm();
88  }
89  }
90 
91  // bring up the update form
92  $rf_pk = @$_REQUEST['rf_pk'];
93  if ($rf_pk) {
94  return $this->Updatefm($rf_pk);
95  }
96 
97  // return a license text
98  if (@$_GET["getLicenseText"] && @$_GET["licenseID"]) {
99  $licenseText = $this->getLicenseTextForID(@$_GET["licenseID"]);
100  if (! $licenseText) {
101  return new Response("Error in querying license text.",
102  Response::HTTP_BAD_REQUEST, array(
103  'Content-type' => 'text/plain'
104  ));
105  }
106  return new Response($licenseText, Response::HTTP_OK,
107  array(
108  'Content-type' => 'text/plain'
109  ));
110  }
111 
112  if (@$_POST["req_shortname"]) {
113  $this->vars += $this->getLicenseListData($_POST["req_shortname"], $_POST["req_marydone"]);
114  }
115  $this->vars['Inputfm'] = $this->Inputfm();
116  return $this->render('admin_license_file.html.twig');
117  }
118 
124  function Inputfm()
125  {
126  $V = "<FORM name='Inputfm' action='?mod=" . $this->Name . "' method='POST'>";
127  $V.= _("What license family do you wish to view:<br>");
128 
129  // qualify by marydone, short name and long name
130  // all are optional
131  $V.= "<p>";
132  $V.= _("Filter: ");
133  $V.= "<select name='req_marydone'>\n";
134  $Selected = (@$_REQUEST['req_marydone'] == 'all') ? " SELECTED ": "";
135  $text = _("All");
136  $V.= "<option value='all' $Selected> $text </option>";
137  $Selected = (@$_REQUEST['req_marydone'] == 'done') ? " SELECTED ": "";
138  $text = _("Checked");
139  $V.= "<option value='done' $Selected> $text </option>";
140  $Selected = (@$_REQUEST['req_marydone'] == 'notdone') ? " SELECTED ": "";
141  $text = _("Not Checked");
142  $V.= "<option value='notdone' $Selected> $text </option>";
143  $V.= "</select>";
144  $V.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
145 
146  // by short name -ajax-> fullname
147  $V.= _("License family name: ");
148  $Shortnamearray = $this->FamilyNames();
149  $Shortnamearray = array("All"=>"All") + $Shortnamearray;
150  $Selected = @$_REQUEST['req_shortname'];
151  $Pulldown = Array2SingleSelect($Shortnamearray, "req_shortname", $Selected);
152  $V.= $Pulldown;
153  $V.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
154  $text = _("Find");
155  $V.= "<INPUT type='submit' value='$text'>\n";
156  $V .= "</FORM>\n";
157  $V.= "<hr>";
158 
159  return $V;
160  }
161 
162 
163  private function getLicenseData($where)
164  {
165  $sql = "SELECT rf_pk, marydone, rf_shortname, rf_spdx_id, " .
166  "rf_shortname, rf_fullname, rf_url, rf_text, ".
167  "string_agg(ob_topic, ';') AS ob_topic " .
168  "FROM ONLY license_ref " .
169  "LEFT OUTER JOIN obligation_map ON rf_fk = rf_pk " .
170  "LEFT OUTER JOIN obligation_ref ON ob_fk = ob_pk " .
171  "$where GROUP BY rf_pk ORDER BY rf_shortname";
172 
173  return $this->dbManager->getRows($sql);
174  }
175 
184  function getLicenseListData($namestr, $filter)
185  {
186  // look at all
187  if ($namestr == "All") {
188  $where = "";
189  } else {
190  $where = "where rf_shortname like '" . pg_escape_string($namestr) . "%' ";
191  }
192 
193  // $filter is one of these: "all", "done", "notdone"
194  if ($filter != "all") {
195  if (empty($where)) {
196  $where .= "where ";
197  } else {
198  $where .= " and ";
199  }
200  if ($filter == "done") {
201  $where .= " marydone=true";
202  }
203  if ($filter == "notdone") {
204  $where .= " marydone=false";
205  }
206  }
207 
208  $data = $this->getLicenseData($where);
209  if (! $data) {
210  $dataMessage = _(
211  "No licenses matching the filter and name pattern were found");
212  } else {
213  $dataSize = sizeof($data);
214  $plural = "";
215 
216  if ($dataSize > 1) {
217  $plural = "s";
218  }
219  $dataMessage = $dataSize . _(" License$plural found");
220  }
221 
222  return array(
223  'data' => $data,
224  'dataMessage' => $dataMessage,
225  'message' => "",
226  'tracebackURI' => Traceback_uri());
227  }
228 
229  function Updatefm($rf_pk)
230  {
231  $this->vars += $this->getUpdatefmData($rf_pk);
232  return $this->render('admin_license-upload_form.html.twig', $this->vars);
233  }
234 
240  function getUpdatefmData($rf_pk)
241  {
242  $vars = array();
243 
244  $rf_pk_update = "";
245 
246  if (0 < count($_POST)) {
247  $rf_pk_update = $_POST['rf_pk'];
248  if (! empty($rf_pk)) {
249  $rf_pk_update = $rf_pk;
250  } else if (empty($rf_pk_update)) {
251  $rf_pk_update = $_GET['rf_pk'];
252  }
253  }
254 
255  $vars['obligationSelectorName'] = $this->obligationSelectorName . "[]";
256  $vars['obligationSelectorId'] = $this->obligationSelectorId;
257 
258  $vars['actionUri'] = "?mod=" . $this->Name . "&rf_pk=$rf_pk_update";
259  $vars['req_marydone'] = array_key_exists('req_marydone', $_POST) ? $_POST['req_marydone'] : '';
260  $vars['req_shortname'] = array_key_exists('req_shortname', $_POST) ? $_POST['req_shortname'] : '';
261  $vars['rf_shortname'] = array_key_exists('rf_shortname', $_POST) ? $_POST['rf_shortname'] : '';
262  $vars['rf_fullname'] = array_key_exists('rf_fullname', $_POST) ? $_POST['rf_fullname'] : '';
263  $vars['rf_text'] = array_key_exists('rf_text', $_POST) ? $_POST['rf_text'] : '';
264  $selectedObligations = array_key_exists($this->obligationSelectorName,
265  $_POST) ? $_POST[$this->obligationSelectorName] : [];
266 
267  $parentMap = new LicenseMap($this->dbManager, 0, LicenseMap::CONCLUSION);
268  $parentLicenes = $parentMap->getTopLevelLicenseRefs();
269  $vars['parentMap'] = array(0=>'[self]');
270  foreach ($parentLicenes as $licRef) {
271  $vars['parentMap'][$licRef->getId()] = $licRef->getShortName();
272  }
273 
274  $reportMap = new LicenseMap($this->dbManager, 0, LicenseMap::REPORT);
275  $reportLicenes = $reportMap->getTopLevelLicenseRefs();
276  $vars['reportMap'] = array(0=>'[self]');
277  foreach ($reportLicenes as $licRef) {
278  $vars['reportMap'][$licRef->getId()] = $licRef->getShortName();
279  }
280 
281  $obligationMap = new ObligationMap($this->dbManager);
282  $obligations = $obligationMap->getObligations();
283  foreach ($obligations as $obligation) {
284  $vars['obligationTopics'][$obligation['ob_pk']] = $obligation['ob_topic'];
285  }
286  foreach ($selectedObligations as $obligation) {
287  $row['obligationSelected'][$obligation] = $obligationMap->getTopicNameFromId(
288  $obligation);
289  }
290 
291  if ($rf_pk > 0) { // true if this is an update
292  $row = $this->dbManager->getSingleRow(
293  "SELECT * FROM ONLY license_ref WHERE rf_pk=$1", array($rf_pk),
294  __METHOD__ . '.forUpdate');
295  if ($row === false) {
296  $text = _("ERROR: No licenses matching this key");
297  $text1 = _("was found");
298  return ["error" => "$text ($rf_pk) $text1."];
299  }
300  $row['rf_parent'] = $parentMap->getProjectedId($rf_pk);
301  $row['rf_report'] = $reportMap->getProjectedId($rf_pk);
302 
303  $obligationsAssigned = $parentMap->getObligationsForLicenseRef($rf_pk);
304  foreach ($obligationsAssigned as $obligation) {
305  $row['obligationSelected'][$obligation] = $obligationMap->getTopicNameFromId(
306  $obligation);
307  }
308  } else {
309  $row = array(
310  'rf_active' => 't',
311  'marydone' => 'f',
312  'rf_text_updatable' => 't',
313  'rf_parent' => 0,
314  'rf_report' => 0,
315  'rf_risk' => 0,
316  'rf_url' => '',
317  'rf_detector_type' => 1,
318  'rf_notes' => ''
319  );
320  }
321 
322  foreach (array_keys($row) as $key) {
323  if (array_key_exists($key, $_POST)) {
324  $row[$key] = $_POST[$key];
325  }
326  }
327 
328  $vars['boolYesNoMap'] = array("true"=>"Yes", "false"=>"No");
329  $row['rf_active'] = $this->isTrue($row['rf_active']) ? 'true' : 'false';
330  $row['marydone'] = $this->isTrue($row['marydone']) ? 'true' : 'false';
331  $row['rf_text_updatable'] = $this->isTrue($row['rf_text_updatable']) ? 'true' : 'false';
332  $vars['risk_level'] = array_key_exists('risk_level', $_POST) ? intval($_POST['risk_level']) : $row['rf_risk'];
333  $vars['isReadOnly'] = !(empty($rf_pk) || $row['rf_text_updatable']=='true');
334  $vars['detectorTypes'] = array("1"=>"Reference License", "2"=>"Nomos", "3"=>"Unconcrete License");
335 
336  $vars['rfId'] = $rf_pk?:$rf_pk_update;
337 
338  return array_merge($vars,$row);
339  }
340 
345  private function isTrue($value)
346  {
347  if (is_bool($value)) {
348  return $value;
349  } else {
350  $value = strtolower($value);
351  return ($value === 't' || $value === 'true');
352  }
353  }
354 
356  private function isShortnameBlocked($rfId, $shortname, $text)
357  {
358  $sql = "SELECT count(*) from license_ref where rf_pk <> $1 and (LOWER(rf_shortname) = LOWER($2) or (rf_text <> ''
359  and rf_text = $3 and LOWER(rf_text) NOT LIKE 'license by nomos.'))";
360  $check_count = $this->dbManager->getSingleRow($sql,
361  array(
362  $rfId,
363  $shortname,
364  $text
365  ), __METHOD__ . '.countLicensesByNomos');
366  return (0 < $check_count['count']);
367  }
368 
370  private function isShortNameExists($rfId, $shortname)
371  {
372  $sql = "SELECT LOWER(rf_shortname) AS rf_shortname FROM license_ref WHERE rf_pk=$1";
373  $row = $this->dbManager->getSingleRow($sql,array($rfId),__METHOD__.'.DoNotChnageShortName');
374  if ($row['rf_shortname'] === strtolower($shortname)) {
375  return 1;
376  } else {
377  return 0;
378  }
379  }
380 
386  function Updatedb()
387  {
388  $spdxLicenses = new SpdxLicenses();
389  $errors = [];
390 
391  $rfId = intval($_POST['rf_pk']);
392  $shortname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_shortname']));
393  $fullname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_fullname']));
394  $url = $_POST['rf_url'];
395  $notes = $_POST['rf_notes'];
396  $text = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_text']));
397  $spdxId = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_spdx_id']));
398  $parent = $_POST['rf_parent'];
399  $report = $_POST['rf_report'];
400  $riskLvl = intval($_POST['risk_level']);
401  $selectedObligations = array_key_exists($this->obligationSelectorName,
402  $_POST) ? $_POST[$this->obligationSelectorName] : [];
403 
404  if (! empty($spdxId) &&
405  strstr(strtolower($spdxId), strtolower(LicenseRef::SPDXREF_PREFIX)) === false) {
406  if (! $spdxLicenses->validate($spdxId)) {
407  $spdxId = LicenseRef::convertToSpdxId($spdxId, null);
408  $errors[] = "SPDX ID changed to $spdxId to be compliant with SPDX.";
409  }
410  } elseif (empty($spdxId)) {
411  $spdxId = null;
412  }
413  if (! empty($spdxId)) {
414  $spdxId = LicenseRef::replaceSpaces($spdxId);
415  }
416 
417  if (empty($shortname)) {
418  $text = _("ERROR: The license shortname is empty. License not added.");
419  return "<b>$text</b><p>";
420  }
421 
422  if (!$this->isShortNameExists($rfId,$shortname)) {
423  $text = _("ERROR: The shortname can not be changed. License not added.");
424  return "<b>$text</b><p>";
425  }
426 
427  $md5term = (empty($text) || stristr($text, "License by Nomos")) ? 'null' : 'md5($10)';
428 
429  $sql = "UPDATE license_ref SET
430  rf_active=$2, marydone=$3, rf_shortname=$4, rf_fullname=$5,
431  rf_url=$6, rf_notes=$7, rf_text_updatable=$8, rf_detector_type=$9, rf_text=$10,
432  rf_md5=$md5term, rf_risk=$11, rf_spdx_id=$12, rf_flag=$13
433  WHERE rf_pk=$1";
434  $params = array($rfId,
435  $_POST['rf_active'],$_POST['marydone'],$shortname,$fullname,
436  $url,$notes,$_POST['rf_text_updatable'],$_POST['rf_detector_type'],$text,
437  $riskLvl,$spdxId,2);
438  $statement = __METHOD__ . ".updateLicense";
439  if ($md5term == "null") {
440  $statement .= ".nullMD5";
441  }
442  $this->dbManager->prepare($statement, $sql);
443  $this->dbManager->freeResult($this->dbManager->execute($statement, $params));
444 
445  $licenseMapDelStatement = __METHOD__ . '.deleteFromMap';
446  $licenseMapDelSql = 'DELETE FROM license_map WHERE rf_fk=$1 AND usage=$2';
447  $this->dbManager->prepare($licenseMapDelStatement, $licenseMapDelSql);
448 
449  $parentMap = new LicenseMap($this->dbManager, 0, LicenseMap::CONCLUSION);
450  if ($parent == 0) {
451  // Update conclusion to self
452  $this->dbManager->execute($licenseMapDelStatement,
453  array($rfId, LicenseMap::CONCLUSION));
454  } else {
455  $parentLicenses = $parentMap->getTopLevelLicenseRefs();
456  if (array_key_exists($parent, $parentLicenses) &&
457  $parent != $parentMap->getProjectedId($rfId)) {
458  $this->dbManager->execute($licenseMapDelStatement,
459  array($rfId, LicenseMap::CONCLUSION));
460  $this->dbManager->insertTableRow('license_map',
461  array('rf_fk'=>$rfId, 'rf_parent'=>$parent, 'usage'=>LicenseMap::CONCLUSION));
462  }
463  }
464 
465  if ($report == 0) {
466  // Update report to self
467  $this->dbManager->execute($licenseMapDelStatement,
468  array($rfId, LicenseMap::REPORT));
469  } else {
470  $reportMap = new LicenseMap($this->dbManager, 0, LicenseMap::REPORT);
471  $reportLicenses = $parentMap->getTopLevelLicenseRefs();
472  if (array_key_exists($report, $reportLicenses) &&
473  $report != $reportMap->getProjectedId($rfId)) {
474  $this->dbManager->execute($licenseMapDelStatement,
475  array($rfId, LicenseMap::REPORT));
476  $this->dbManager->insertTableRow('license_map',
477  array('rf_fk'=>$rfId, 'rf_parent'=>$report, 'usage'=>LicenseMap::REPORT));
478  }
479  }
480 
481  $obligationMap = new ObligationMap($this->dbManager);
482  foreach ($selectedObligations as $obligation) {
483  $obligationMap->associateLicenseWithObligation($obligation, $rfId);
484  }
485 
486  $allObligations = $parentMap->getObligationsForLicenseRef($rfId);
487  $removedObligations = array_diff($allObligations, $selectedObligations);
488  foreach ($removedObligations as $obligation) {
489  $obligationMap->unassociateLicenseFromObligation($obligation, $rfId);
490  }
491 
492  return "License $_POST[rf_shortname] updated. " . join(" ", $errors) . "<p>";
493  }
494 
495 
501  function Adddb()
502  {
503  $spdxLicenses = new SpdxLicenses();
504  $errors = [];
505 
506  $rf_shortname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_shortname']));
507  $rf_fullname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_fullname']));
508  $rf_spdx_id = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_spdx_id']));
509  $rf_url = $_POST['rf_url'];
510  $rf_notes = $_POST['rf_notes'];
511  $rf_text = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_text']));
512  $parent = $_POST['rf_parent'];
513  $report = $_POST['rf_report'];
514  $riskLvl = intval($_POST['risk_level']);
515  $selectedObligations = array_key_exists($this->obligationSelectorName,
516  $_POST) ? $_POST[$this->obligationSelectorName] : [];
517 
518  if (! empty($rf_spdx_id) &&
519  strstr(strtolower($rf_spdx_id), strtolower(LicenseRef::SPDXREF_PREFIX)) === false) {
520  if (! $spdxLicenses->validate($rf_spdx_id)) {
521  $rf_spdx_id = LicenseRef::convertToSpdxId($rf_spdx_id, null);
522  $errors[] = "SPDX ID changed to $rf_spdx_id to be compliant with SPDX.";
523  }
524  } elseif (empty($rf_spdx_id)) {
525  $rf_spdx_id = null;
526  }
527  if (! empty($rf_spdx_id)) {
528  $rf_spdx_id = LicenseRef::replaceSpaces($rf_spdx_id);
529  }
530 
531  if (empty($rf_shortname)) {
532  $text = _("ERROR: The license shortname is empty. License not added.");
533  return "<b>$text</b><p>";
534  }
535 
536  if ($this->isShortnameBlocked(0,$rf_shortname,$rf_text)) {
537  $text = _("ERROR: The shortname or license text already exist in the license list. License not added.");
538  return "<b>$text</b><p>";
539  }
540 
541  $md5term = (empty($rf_text) || stristr($rf_text, "License by Nomos")) ? 'null' : 'md5($7)';
542  $stmt = __METHOD__.'.rf';
543  $sql = "INSERT into license_ref (
544  rf_active, marydone, rf_shortname, rf_fullname,
545  rf_url, rf_notes, rf_md5, rf_text, rf_text_updatable,
546  rf_detector_type, rf_risk, rf_spdx_id)
547  VALUES (
548  $1, $2, $3, $4, $5, $6, $md5term, $7, $8, $9, $10, $11) RETURNING rf_pk";
549  $this->dbManager->prepare($stmt,$sql);
550  $res = $this->dbManager->execute($stmt,
551  array(
552  $_POST['rf_active'],
553  $_POST['marydone'],
554  $rf_shortname,
555  $rf_fullname,
556  $rf_url,
557  $rf_notes,
558  $rf_text,
559  $_POST['rf_text_updatable'],
560  $_POST['rf_detector_type'],
561  $riskLvl,
562  $rf_spdx_id
563  ));
564  $row = $this->dbManager->fetchArray($res);
565  $rfId = $row['rf_pk'];
566 
567  $parentMap = new LicenseMap($this->dbManager, 0, LicenseMap::CONCLUSION);
568  $parentLicenses = $parentMap->getTopLevelLicenseRefs();
569  if (array_key_exists($parent, $parentLicenses)) {
570  $this->dbManager->insertTableRow('license_map',
571  array(
572  'rf_fk' => $rfId,
573  'rf_parent' => $parent,
574  'usage' => LicenseMap::CONCLUSION
575  ));
576  }
577 
578  $reportMap = new LicenseMap($this->dbManager, 0, LicenseMap::REPORT);
579  $reportLicenses = $reportMap->getTopLevelLicenseRefs();
580  if (array_key_exists($report, $reportLicenses)) {
581  $this->dbManager->insertTableRow('license_map',
582  array(
583  'rf_fk' => $rfId,
584  'rf_parent' => $report,
585  'usage' => LicenseMap::REPORT
586  ));
587  }
588 
589  $obligationMap = new ObligationMap($this->dbManager);
590  foreach ($selectedObligations as $obligation) {
591  $obligationMap->associateLicenseWithObligation($obligation, $rfId);
592  }
593 
594  return "License $_POST[rf_shortname] (id=$rfId) added. " .
595  join(" ", $errors) . "<p>";
596  }
597 
598 
608  function FamilyNames()
609  {
610  $familynamearray = array();
611  $Shortnamearray = DB2KeyValArray("license_ref", "rf_pk", "rf_shortname", " order by rf_shortname");
612 
613  // truncate each name to the family name
614  foreach ($Shortnamearray as $shortname) {
615  // start with exceptions
616  if (($shortname == "No_license_found") || ($shortname == "Unknown license")) {
617  $familynamearray[$shortname] = $shortname;
618  } else {
619  $tok = strtok($shortname, " _-([/");
620  $familynamearray[$tok] = $tok;
621  }
622  }
623 
624  return ($familynamearray);
625  }
626 
627  private function getLicenseTextForID($licenseID)
628  {
629  $license = $this->licenseDao->getLicenseById($licenseID);
630 
631  if ($license == null) {
632  return false;
633  }
634  return $license->getText();
635  }
636 }
637 
638 $NewPlugin = new admin_license_file();
This is the Plugin class. All plugins should:
Definition: FO_Plugin.php:57
render($templateName, $vars=null)
Definition: FO_Plugin.php:434
Wrapper class for license map.
Definition: LicenseMap.php:19
Wrapper class for obligation map.
Definition: state.hpp:16
__construct()
base constructor. Most plugins will just use this
RegisterMenus()
Customize submenus.
Output()
This function is called when user output is requested. This function is responsible for content....
isShortnameBlocked($rfId, $shortname, $text)
check if shortname or license text of this license is existing
Inputfm()
Build the input form.
Updatedb()
Update the database.
getUpdatefmData($rf_pk)
Update forms.
isTrue($value)
Check if a variable is true.
getLicenseListData($namestr, $filter)
Build the input form.
Adddb()
Add a new license_ref to the database.
isShortNameExists($rfId, $shortname)
check if shortname is changed
DB2KeyValArray($Table, $KeyCol, $ValCol, $Where="")
Create an associative array by using table rows to source the key/value pairs.
Definition: common-db.php:121
menu_insert($Path, $LastOrder=0, $URI=NULL, $Title=NULL, $Target=NULL, $HTML=NULL)
Given a Path, order level for the last item, and optional plugin name, insert the menu item.
Traceback_uri()
Get the URI without query to this location.
Definition: common-parm.php:97
Array2SingleSelect($KeyValArray, $SLName="unnamed", $SelectedVal="", $FirstEmpty=false, $SelElt=true, $Options="", $ReturnKey=true)
Build a single choice select pulldown.
Definition: common-ui.php:32
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:690
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
Definition: libfossology.h:39
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16