12 namespace Fossology\Lib\Dao;
44 $where =
"WHERE name <> 'not-set' AND is_enabled = TRUE";
46 $sql =
"SELECT la_pk, name, acknowledgement, is_enabled " .
47 "FROM license_std_acknowledgement $where " .
48 "ORDER BY la_pk ASC;";
69 $sql =
"UPDATE license_std_acknowledgement " .
70 "SET name = $2, acknowledgement = $3, updated = NOW(), user_fk = $4 " .
72 "RETURNING 1 AS updated;";
73 $row = $this->
dbManager->getSingleRow($sql,
74 [$acknowledgementPk, $newName,
76 return $row[
'updated'] == 1;
95 $acknowledgement =
trim($acknowledgement);
97 if (empty($name) || empty($acknowledgement)) {
109 $statement = __METHOD__ .
".insertNewLicAcknowledgement";
110 $returning =
"la_pk";
113 $returnVal = $this->
dbManager->insertTableRow(
"license_std_acknowledgement",
114 $params, $statement, $returning);
141 foreach ($acknowledgementArray as $acknowledgementPk => $acknowledgement) {
142 if (count($acknowledgement) < 1 ||
143 (! array_key_exists(
"name", $acknowledgement) &&
144 ! array_key_exists(
"acknowledgement", $acknowledgement))) {
145 throw new \UnexpectedValueException(
146 "At least name or acknowledgement is " .
"required for entry " . $acknowledgementPk);
149 $statement = __METHOD__;
150 $params = [$acknowledgementPk, $userFk];
151 $updateStatement = [];
152 if (array_key_exists(
"name", $acknowledgement)) {
153 $params[] = $acknowledgement[
"name"];
154 $updateStatement[] =
"name = $" . count($params);
155 $statement .=
".name";
157 if (array_key_exists(
"acknowledgement", $acknowledgement)) {
159 $updateStatement[] =
"acknowledgement = $" . count($params);
160 $statement .=
".acknowledgement";
162 $sql =
"UPDATE license_std_acknowledgement " .
163 "SET updated = NOW(), user_fk = $2, " . join(
",", $updateStatement) .
164 "WHERE la_pk = $1 " .
165 "RETURNING 1 AS updated;";
166 $retVal = $this->
dbManager->getSingleRow($sql, $params, $statement);
167 $updated += intval($retVal);
180 $sql =
"SELECT acknowledgement FROM license_std_acknowledgement " .
"WHERE la_pk = $1;";
181 $statement = __METHOD__ .
".getAcknowledgement";
183 $acknowledgement = $this->
dbManager->getSingleRow($sql, [$acknowledgementPk], $statement);
184 $acknowledgement = $acknowledgement[
'acknowledgement'];
185 if (strcasecmp($acknowledgement,
"null") === 0) {
188 return $acknowledgement;
207 $sql =
"UPDATE license_std_acknowledgement " .
208 "SET is_enabled = NOT is_enabled, user_fk = $2 " .
211 $this->
dbManager->getSingleRow($sql, [$acknowledgementPk, $userFk]);
223 if (! is_int($acknowledgementPk)) {
224 throw new \UnexpectedValueException(
"Inavlid acknowledgement id");
226 $sql =
"SELECT count(*) AS cnt FROM license_std_acknowledgement " .
229 $acknowledgementCount = $this->
dbManager->getSingleRow($sql, [$acknowledgementPk]);
230 if ($acknowledgementCount[
'cnt'] < 1) {
232 throw new \UnexpectedValueException(
"Inavlid acknowledgement id");
Contains the constants and helpers for authentication of user.
static getUserId()
Get the current user's id.
static isAdmin()
Check if user is admin.
updateAcknowledgementFromArray($acknowledgementArray)
Update the acknowledgements based only on the values provided.
insertAcknowledgement($name, $acknowledgement)
isAcknowledgementIdValid($acknowledgementPk)
toggleAcknowledgement($acknowledgementPk)
updateAcknowledgement($acknowledgementPk, $newName, $newAcknowledgement)
getAllAcknowledgements($skipNotSet=false)
getAcknowledgement($acknowledgementPk)
static replaceUnicodeControlChar($input, $replace="")
char * trim(char *ptext)
Trimming whitespace.
fo_dbManager * dbManager
fo_dbManager object