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  global $SysConf;
243  $vars = array();
244 
245  $rf_pk_update = "";
246 
247  if (0 < count($_POST)) {
248  $rf_pk_update = $_POST['rf_pk'];
249  if (! empty($rf_pk)) {
250  $rf_pk_update = $rf_pk;
251  } else if (empty($rf_pk_update)) {
252  $rf_pk_update = $_GET['rf_pk'];
253  }
254  }
255 
256  $vars['obligationSelectorName'] = $this->obligationSelectorName . "[]";
257  $vars['obligationSelectorId'] = $this->obligationSelectorId;
258 
259  $vars['actionUri'] = "?mod=" . $this->Name . "&rf_pk=$rf_pk_update";
260  $vars['req_marydone'] = array_key_exists('req_marydone', $_POST) ? $_POST['req_marydone'] : '';
261  $vars['req_shortname'] = array_key_exists('req_shortname', $_POST) ? $_POST['req_shortname'] : '';
262  $vars['rf_shortname'] = array_key_exists('rf_shortname', $_POST) ? $_POST['rf_shortname'] : '';
263  $vars['rf_fullname'] = array_key_exists('rf_fullname', $_POST) ? $_POST['rf_fullname'] : '';
264  $vars['rf_text'] = array_key_exists('rf_text', $_POST) ? $_POST['rf_text'] : '';
265  $vars['rf_licensetype'] = array_key_exists('rf_licensetype', $_POST) ? $_POST['rf_licensetype'] : '---';
266  $selectedObligations = array_key_exists($this->obligationSelectorName,
267  $_POST) ? $_POST[$this->obligationSelectorName] : [];
268 
269  $parentMap = new LicenseMap($this->dbManager, 0, LicenseMap::CONCLUSION);
270  $parentLicenes = $parentMap->getTopLevelLicenseRefs();
271  $vars['parentMap'] = array(0=>'[self]');
272  foreach ($parentLicenes as $licRef) {
273  $vars['parentMap'][$licRef->getId()] = $licRef->getShortName();
274  }
275 
276  $reportMap = new LicenseMap($this->dbManager, 0, LicenseMap::REPORT);
277  $reportLicenes = $reportMap->getTopLevelLicenseRefs();
278  $vars['reportMap'] = array(0=>'[self]');
279  foreach ($reportLicenes as $licRef) {
280  $vars['reportMap'][$licRef->getId()] = $licRef->getShortName();
281  }
282 
283  $obligationMap = new ObligationMap($this->dbManager);
284  $obligations = $obligationMap->getObligations();
285  foreach ($obligations as $obligation) {
286  $vars['obligationTopics'][$obligation['ob_pk']] = $obligation['ob_topic'];
287  }
288  foreach ($selectedObligations as $obligation) {
289  $row['obligationSelected'][$obligation] = $obligationMap->getTopicNameFromId(
290  $obligation);
291  }
292 
293  if ($rf_pk > 0) { // true if this is an update
294  $row = $this->dbManager->getSingleRow(
295  "SELECT * FROM ONLY license_ref WHERE rf_pk=$1", array($rf_pk),
296  __METHOD__ . '.forUpdate');
297  if ($row === false) {
298  $text = _("ERROR: No licenses matching this key");
299  $text1 = _("was found");
300  return ["error" => "$text ($rf_pk) $text1."];
301  }
302  $row['rf_parent'] = $parentMap->getProjectedId($rf_pk);
303  $row['rf_report'] = $reportMap->getProjectedId($rf_pk);
304 
305  $obligationsAssigned = $parentMap->getObligationsForLicenseRef($rf_pk);
306  foreach ($obligationsAssigned as $obligation) {
307  $row['obligationSelected'][$obligation] = $obligationMap->getTopicNameFromId(
308  $obligation);
309  }
310  } else {
311  $row = array(
312  'rf_active' => 't',
313  'marydone' => 'f',
314  'rf_text_updatable' => 't',
315  'rf_parent' => 0,
316  'rf_report' => 0,
317  'rf_risk' => 0,
318  'rf_url' => '',
319  'rf_detector_type' => 1,
320  'rf_notes' => '',
321  'rf_licensetype' => 'Permissive'
322  );
323  }
324 
325  foreach (array_keys($row) as $key) {
326  if (array_key_exists($key, $_POST)) {
327  $row[$key] = $_POST[$key];
328  }
329  }
330 
331  $vars['boolYesNoMap'] = array("true"=>"Yes", "false"=>"No");
332  $row['rf_active'] = $this->isTrue($row['rf_active']) ? 'true' : 'false';
333  $row['marydone'] = $this->isTrue($row['marydone']) ? 'true' : 'false';
334  $row['rf_text_updatable'] = $this->isTrue($row['rf_text_updatable']) ? 'true' : 'false';
335  $vars['risk_level'] = array_key_exists('risk_level', $_POST) ? intval($_POST['risk_level']) : $row['rf_risk'];
336  $vars['isReadOnly'] = !(empty($rf_pk) || $row['rf_text_updatable']=='true');
337  $vars['detectorTypes'] = array("1"=>"Reference License", "2"=>"Nomos", "3"=>"Unconcrete License");
338  $licenseType = $SysConf['SYSCONFIG']['LicenseTypes'];
339  $licenseType = explode(',', $licenseType);
340  $licenseType = array_map('trim', $licenseType);
341  $vars['licenseTypes'] = array_combine($licenseType, $licenseType);
342  $vars['rfId'] = $rf_pk?:$rf_pk_update;
343 
344  return array_merge($vars,$row);
345  }
346 
351  private function isTrue($value)
352  {
353  if (is_bool($value)) {
354  return $value;
355  } else {
356  $value = strtolower($value);
357  return ($value === 't' || $value === 'true');
358  }
359  }
360 
362  private function isShortnameBlocked($rfId, $shortname, $text)
363  {
364  $sql = "SELECT count(*) from license_ref where rf_pk <> $1 and (LOWER(rf_shortname) = LOWER($2) or (rf_text <> ''
365  and rf_text = $3 and LOWER(rf_text) NOT LIKE 'license by nomos.'))";
366  $check_count = $this->dbManager->getSingleRow($sql,
367  array(
368  $rfId,
369  $shortname,
370  $text
371  ), __METHOD__ . '.countLicensesByNomos');
372  return (0 < $check_count['count']);
373  }
374 
376  private function isShortNameExists($rfId, $shortname)
377  {
378  $sql = "SELECT LOWER(rf_shortname) AS rf_shortname FROM license_ref WHERE rf_pk=$1";
379  $row = $this->dbManager->getSingleRow($sql,array($rfId),__METHOD__.'.DoNotChnageShortName');
380  if ($row['rf_shortname'] === strtolower($shortname)) {
381  return 1;
382  } else {
383  return 0;
384  }
385  }
386 
392  function Updatedb()
393  {
394  $spdxLicenses = new SpdxLicenses();
395  $errors = [];
396 
397  $rfId = intval($_POST['rf_pk']);
398  $shortname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_shortname']));
399  $fullname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_fullname']));
400  $url = $_POST['rf_url'];
401  $notes = $_POST['rf_notes'];
402  $text = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_text']));
403  $spdxId = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_spdx_id']));
404  $parent = $_POST['rf_parent'];
405  $report = $_POST['rf_report'];
406  $licensetype = trim($_POST['rf_licensetype']);
407  $riskLvl = intval($_POST['risk_level']);
408  $selectedObligations = array_key_exists($this->obligationSelectorName,
409  $_POST) ? $_POST[$this->obligationSelectorName] : [];
410 
411  if (! empty($spdxId) &&
412  strstr(strtolower($spdxId), strtolower(LicenseRef::SPDXREF_PREFIX)) === false) {
413  if (! $spdxLicenses->validate($spdxId)) {
414  $spdxId = LicenseRef::convertToSpdxId($spdxId, null);
415  $errors[] = "SPDX ID changed to $spdxId to be compliant with SPDX.";
416  }
417  } elseif (empty($spdxId)) {
418  $spdxId = null;
419  }
420  if (! empty($spdxId)) {
421  $spdxId = LicenseRef::replaceSpaces($spdxId);
422  }
423 
424  if (empty($shortname)) {
425  $text = _("ERROR: The license shortname is empty. License not added.");
426  return "<b>$text</b><p>";
427  }
428 
429  if (!$this->isShortNameExists($rfId,$shortname)) {
430  $text = _("ERROR: The shortname can not be changed. License not added.");
431  return "<b>$text</b><p>";
432  }
433 
434  $md5term = (empty($text) || stristr($text, "License by Nomos")) ? 'null' : 'md5($10)';
435 
436  $sql = "UPDATE license_ref SET
437  rf_active=$2, marydone=$3, rf_shortname=$4, rf_fullname=$5,
438  rf_url=$6, rf_notes=$7, rf_text_updatable=$8, rf_detector_type=$9, rf_text=$10,
439  rf_md5=$md5term, rf_risk=$11, rf_spdx_id=$12, rf_flag=$13, rf_licensetype=$14
440  WHERE rf_pk=$1";
441  $params = array($rfId,
442  $_POST['rf_active'],$_POST['marydone'],$shortname,$fullname,
443  $url,$notes,$_POST['rf_text_updatable'],$_POST['rf_detector_type'],$text,
444  $riskLvl,$spdxId,2, $licensetype);
445  $statement = __METHOD__ . ".updateLicense";
446  if ($md5term == "null") {
447  $statement .= ".nullMD5";
448  }
449  $this->dbManager->prepare($statement, $sql);
450  $this->dbManager->freeResult($this->dbManager->execute($statement, $params));
451 
452  $licenseMapDelStatement = __METHOD__ . '.deleteFromMap';
453  $licenseMapDelSql = 'DELETE FROM license_map WHERE rf_fk=$1 AND usage=$2';
454  $this->dbManager->prepare($licenseMapDelStatement, $licenseMapDelSql);
455 
456  $parentMap = new LicenseMap($this->dbManager, 0, LicenseMap::CONCLUSION);
457  if ($parent == 0) {
458  // Update conclusion to self
459  $this->dbManager->execute($licenseMapDelStatement,
460  array($rfId, LicenseMap::CONCLUSION));
461  } else {
462  $parentLicenses = $parentMap->getTopLevelLicenseRefs();
463  if (array_key_exists($parent, $parentLicenses) &&
464  $parent != $parentMap->getProjectedId($rfId)) {
465  $this->dbManager->execute($licenseMapDelStatement,
466  array($rfId, LicenseMap::CONCLUSION));
467  $this->dbManager->insertTableRow('license_map',
468  array('rf_fk'=>$rfId, 'rf_parent'=>$parent, 'usage'=>LicenseMap::CONCLUSION));
469  }
470  }
471 
472  if ($report == 0) {
473  // Update report to self
474  $this->dbManager->execute($licenseMapDelStatement,
475  array($rfId, LicenseMap::REPORT));
476  } else {
477  $reportMap = new LicenseMap($this->dbManager, 0, LicenseMap::REPORT);
478  $reportLicenses = $parentMap->getTopLevelLicenseRefs();
479  if (array_key_exists($report, $reportLicenses) &&
480  $report != $reportMap->getProjectedId($rfId)) {
481  $this->dbManager->execute($licenseMapDelStatement,
482  array($rfId, LicenseMap::REPORT));
483  $this->dbManager->insertTableRow('license_map',
484  array('rf_fk'=>$rfId, 'rf_parent'=>$report, 'usage'=>LicenseMap::REPORT));
485  }
486  }
487 
488  $obligationMap = new ObligationMap($this->dbManager);
489  foreach ($selectedObligations as $obligation) {
490  $obligationMap->associateLicenseWithObligation($obligation, $rfId);
491  }
492 
493  $allObligations = $parentMap->getObligationsForLicenseRef($rfId);
494  $removedObligations = array_diff($allObligations, $selectedObligations);
495  foreach ($removedObligations as $obligation) {
496  $obligationMap->unassociateLicenseFromObligation($obligation, $rfId);
497  }
498 
499  return "License $_POST[rf_shortname] updated. " . join(" ", $errors) . "<p>";
500  }
501 
502 
508  function Adddb()
509  {
510  $spdxLicenses = new SpdxLicenses();
511  $errors = [];
512 
513  $rf_shortname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_shortname']));
514  $rf_fullname = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_fullname']));
515  $rf_spdx_id = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_spdx_id']));
516  $rf_url = $_POST['rf_url'];
517  $rf_notes = $_POST['rf_notes'];
518  $rf_text = StringOperation::replaceUnicodeControlChar(trim($_POST['rf_text']));
519  $rf_licensetype = trim($_POST['rf_licensetype']);
520  $parent = $_POST['rf_parent'];
521  $report = $_POST['rf_report'];
522  $riskLvl = intval($_POST['risk_level']);
523  $selectedObligations = array_key_exists($this->obligationSelectorName,
524  $_POST) ? $_POST[$this->obligationSelectorName] : [];
525 
526  if (! empty($rf_spdx_id) &&
527  strstr(strtolower($rf_spdx_id), strtolower(LicenseRef::SPDXREF_PREFIX)) === false) {
528  if (! $spdxLicenses->validate($rf_spdx_id)) {
529  $rf_spdx_id = LicenseRef::convertToSpdxId($rf_spdx_id, null);
530  $errors[] = "SPDX ID changed to $rf_spdx_id to be compliant with SPDX.";
531  }
532  } elseif (empty($rf_spdx_id)) {
533  $rf_spdx_id = null;
534  }
535  if (! empty($rf_spdx_id)) {
536  $rf_spdx_id = LicenseRef::replaceSpaces($rf_spdx_id);
537  }
538 
539  if (empty($rf_shortname)) {
540  $text = _("ERROR: The license shortname is empty. License not added.");
541  return "<b>$text</b><p>";
542  }
543 
544  if ($this->isShortnameBlocked(0,$rf_shortname,$rf_text)) {
545  $text = _("ERROR: The shortname or license text already exist in the license list. License not added.");
546  return "<b>$text</b><p>";
547  }
548 
549  $md5term = (empty($rf_text) || stristr($rf_text, "License by Nomos")) ? 'null' : 'md5($7)';
550  $stmt = __METHOD__.'.rf';
551  $sql = "INSERT into license_ref (
552  rf_active, marydone, rf_shortname, rf_fullname,
553  rf_url, rf_notes, rf_md5, rf_text, rf_text_updatable,
554  rf_detector_type, rf_risk, rf_spdx_id, rf_licensetype)
555  VALUES (
556  $1, $2, $3, $4, $5, $6, $md5term, $7, $8, $9, $10, $11, $12) RETURNING rf_pk";
557  $this->dbManager->prepare($stmt,$sql);
558  $res = $this->dbManager->execute($stmt,
559  array(
560  $_POST['rf_active'],
561  $_POST['marydone'],
562  $rf_shortname,
563  $rf_fullname,
564  $rf_url,
565  $rf_notes,
566  $rf_text,
567  $_POST['rf_text_updatable'],
568  $_POST['rf_detector_type'],
569  $riskLvl,
570  $rf_spdx_id,
571  $rf_licensetype
572  ));
573  $row = $this->dbManager->fetchArray($res);
574  $rfId = $row['rf_pk'];
575 
576  $parentMap = new LicenseMap($this->dbManager, 0, LicenseMap::CONCLUSION);
577  $parentLicenses = $parentMap->getTopLevelLicenseRefs();
578  if (array_key_exists($parent, $parentLicenses)) {
579  $this->dbManager->insertTableRow('license_map',
580  array(
581  'rf_fk' => $rfId,
582  'rf_parent' => $parent,
583  'usage' => LicenseMap::CONCLUSION
584  ));
585  }
586 
587  $reportMap = new LicenseMap($this->dbManager, 0, LicenseMap::REPORT);
588  $reportLicenses = $reportMap->getTopLevelLicenseRefs();
589  if (array_key_exists($report, $reportLicenses)) {
590  $this->dbManager->insertTableRow('license_map',
591  array(
592  'rf_fk' => $rfId,
593  'rf_parent' => $report,
594  'usage' => LicenseMap::REPORT
595  ));
596  }
597 
598  $obligationMap = new ObligationMap($this->dbManager);
599  foreach ($selectedObligations as $obligation) {
600  $obligationMap->associateLicenseWithObligation($obligation, $rfId);
601  }
602 
603  return "License $_POST[rf_shortname] (id=$rfId) added. " .
604  join(" ", $errors) . "<p>";
605  }
606 
607 
617  function FamilyNames()
618  {
619  $familynamearray = array();
620  $Shortnamearray = DB2KeyValArray("license_ref", "rf_pk", "rf_shortname", " order by rf_shortname");
621 
622  // truncate each name to the family name
623  foreach ($Shortnamearray as $shortname) {
624  // start with exceptions
625  if (($shortname == "No_license_found") || ($shortname == "Unknown license")) {
626  $familynamearray[$shortname] = $shortname;
627  } else {
628  $tok = strtok($shortname, " _-([/");
629  $familynamearray[$tok] = $tok;
630  }
631  }
632 
633  return ($familynamearray);
634  }
635 
636  private function getLicenseTextForID($licenseID)
637  {
638  $license = $this->licenseDao->getLicenseById($licenseID);
639 
640  if ($license == null) {
641  return false;
642  }
643  return $license->getText();
644  }
645 }
646 
647 $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