Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
What's new
2
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiki Wiki CMS Groupware
Tiki
Commits
ffad70af
Commit
ffad70af
authored
Jan 25, 2023
by
Victor Emanouilov
Browse files
[ENH] add goalId to credits when rewarding credits to users via reached goals
parent
b8e1cfa2
Pipeline
#757341390
passed with stages
in 8 minutes and 41 seconds
Changes
6
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
db/tiki.sql
View file @
ffad70af
...
...
@@ -3748,6 +3748,7 @@ CREATE TABLE `tiki_credits` (
`total_amount`
FLOAT
NOT
NULL
DEFAULT
0
,
`used_amount`
FLOAT
NOT
NULL
DEFAULT
0
,
`product_id`
INT
(
8
)
NULL
,
`goalId`
INT
NULL
,
PRIMARY
KEY
(
`creditId`
)
,
INDEX
(
`userId`
,
`credit_type`
)
)
ENGINE
=
MyISAM
;
...
...
installer/schema/20230125_add_goalid_to_credits_tiki.sql
0 → 100644
View file @
ffad70af
ALTER
TABLE
`tiki_credits`
ADD
`goalId`
INT
NULL
;
lib/core/Search/ContentSource/CreditSource.php
View file @
ffad70af
...
...
@@ -33,7 +33,7 @@ class CreditSource implements Search_ContentSource_Interface
$credit_types
=
TikiLib
::
lib
(
'credits'
)
->
getCreditTypes
();
$credit
=
$this
->
table
->
fetchRow
([
'userId'
,
'credit_type'
,
'creation_date'
,
'expiration_date'
,
'total_amount'
,
'used_amount'
,
'product_id'
],
[
$credit
=
$this
->
table
->
fetchRow
([
'userId'
,
'credit_type'
,
'creation_date'
,
'expiration_date'
,
'total_amount'
,
'used_amount'
,
'product_id'
,
'goalId'
],
[
'creditId'
=>
$objectId
,
]);
...
...
@@ -59,6 +59,7 @@ class CreditSource implements Search_ContentSource_Interface
'total_amount'
=>
$typeFactory
->
numeric
(
$credit
[
'total_amount'
]),
'used_amount'
=>
$typeFactory
->
numeric
(
$credit
[
'used_amount'
]),
'product_id'
=>
$typeFactory
->
numeric
(
$credit
[
'product_id'
]),
'goal_id'
=>
$typeFactory
->
numeric
(
$credit
[
'goalId'
]),
'allowed_groups'
=>
$typeFactory
->
multivalue
([
'Anonymous'
,
'Registered'
]),
];
}
else
{
...
...
@@ -71,7 +72,7 @@ class CreditSource implements Search_ContentSource_Interface
return
[
'title'
,
'creation_date'
,
'expiration_date'
,
'contributors'
,
'user'
,
'credit_type'
,
'credit_type_text'
,
'credit_type_unit'
,
'credit_type_static_level'
,
'credit_type_scaling_divisor'
,
'total_amonut'
,
'used_amount'
,
'product_id'
'total_amonut'
,
'used_amount'
,
'product_id'
,
'goal_id'
];
}
...
...
@@ -91,6 +92,7 @@ class CreditSource implements Search_ContentSource_Interface
'total_amount'
=>
'numeric'
,
'used_amount'
=>
'numeric'
,
'product_id'
=>
'numeric'
,
'goal_id'
=>
'numeric'
,
];
}
...
...
lib/credits/creditslib.php
View file @
ffad70af
...
...
@@ -199,7 +199,7 @@ class CreditsLib extends TikiLib
/**
* Adds a new credits entry for the user.
*/
public
function
addCredits
(
$userId
,
$creditType
,
$amount
,
$expirationDate
=
null
,
$validFrom
=
null
)
public
function
addCredits
(
$userId
,
$creditType
,
$amount
,
$expirationDate
=
null
,
$validFrom
=
null
,
$goalId
=
null
)
{
if
(
!
$amount
)
{
return
false
;
...
...
@@ -225,9 +225,9 @@ class CreditsLib extends TikiLib
$this
->
query
(
"INSERT INTO `tiki_credits`
(`userId`, `credit_type`, `total_amount`, `expiration_date`, `creation_date`)
VALUES(?,?,?,if (? = '', NULL, ?),if (?='', NULL, ?))"
,
[
$userId
,
$creditType
,
$amount
,
$expirationDate
,
$expirationDate
,
$validFrom
,
$validFrom
]
(`userId`, `credit_type`, `total_amount`, `expiration_date`, `creation_date`
, `goalId`
)
VALUES(?,?,?,if (? = '', NULL, ?),if (?='', NULL, ?)
,?
)"
,
[
$userId
,
$creditType
,
$amount
,
$expirationDate
,
$expirationDate
,
$validFrom
,
$validFrom
,
$goalId
]
);
return
true
;
...
...
lib/goal/goallib.php
View file @
ffad70af
...
...
@@ -168,6 +168,12 @@ class GoalLib
'group'
=>
$context
[
'group'
],
]);
if
(
!
empty
(
$goal
[
'rewards'
]))
{
foreach
(
$goal
[
'rewards'
]
as
&
$reward
)
{
$reward
[
'goalId'
]
=
$goal
[
'goalId'
];
}
}
$rewardlib
=
TikiLib
::
lib
(
'goalreward'
);
if
(
$goal
[
'type'
]
==
'group'
)
{
$rewardlib
->
giveRewardsToMembers
(
$context
[
'group'
],
$goal
[
'rewards'
]);
...
...
lib/goal/rewardlib.php
View file @
ffad70af
...
...
@@ -63,7 +63,7 @@ class GoalRewardLib
if
(
!
empty
(
$creditTypes
[
$reward
[
'creditType'
]]))
{
$userId
=
TikiLib
::
lib
(
'tiki'
)
->
get_user_id
(
$user
);
$lib
=
TikiLib
::
lib
(
'credits'
);
$lib
->
addCredits
(
$userId
,
$reward
[
'creditType'
],
$reward
[
'creditQuantity'
]);
$lib
->
addCredits
(
$userId
,
$reward
[
'creditType'
],
$reward
[
'creditQuantity'
]
,
null
,
null
,
$reward
[
'goalId'
]
??
null
);
}
},
'applyGroup'
=>
function
(
$group
,
$reward
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment