mirror of
https://github.com/documize/community.git
synced 2025-07-18 20:59:43 +02:00
Make store SQL Server compatible
This commit is contained in:
parent
9ec858286f
commit
64403c402b
17 changed files with 112 additions and 50 deletions
|
@ -28,6 +28,8 @@ func RebindParams(sql string, s env.StoreType) string {
|
|||
switch s {
|
||||
case env.StoreTypePostgreSQL:
|
||||
bindParam = sqlx.DOLLAR
|
||||
case env.StoreTypeSQLServer:
|
||||
bindParam = sqlx.AT
|
||||
}
|
||||
|
||||
return sqlx.Rebind(bindParam, sql)
|
||||
|
|
8
core/env/provider.go
vendored
8
core/env/provider.go
vendored
|
@ -103,4 +103,12 @@ type StoreProvider interface {
|
|||
// Must use ? for parameter placeholder character as DB layer
|
||||
// will convert to database specific parameter placeholder character.
|
||||
ConvertTimestamp() (statement string)
|
||||
|
||||
// IsTrue returns storage provider boolean TRUE:
|
||||
// MySQL is 1, PostgresSQL is TRUE, SQL Server is 1
|
||||
IsTrue() string
|
||||
|
||||
// IsFalse returns storage provider boolean FALSE:
|
||||
// MySQL is 0, PostgresSQL is FALSE, SQL Server is 0
|
||||
IsFalse() string
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ func (s Store) GetUserAccounts(ctx domain.RequestContext, userID string) (t []ac
|
|||
a.c_active AS active, a.c_created AS created, a.c_revised AS revised,
|
||||
b.c_company AS company, b.c_title AS title, b.c_message AS message, b.c_domain as domain
|
||||
FROM dmz_user_account a, dmz_org b
|
||||
WHERE a.c_userid=? AND a.c_orgid=b.c_refid AND a.c_active=true
|
||||
WHERE a.c_userid=? AND a.c_orgid=b.c_refid AND a.c_active=`+s.IsTrue()+`
|
||||
ORDER BY b.c_title`),
|
||||
userID)
|
||||
|
||||
|
@ -88,7 +88,7 @@ func (s Store) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account,
|
|||
a.c_active AS active, a.c_created AS created, a.c_revised AS revised,
|
||||
b.c_company AS company, b.c_title AS title, b.c_message AS message, b.c_domain as domain
|
||||
FROM dmz_user_account a, dmz_org b
|
||||
WHERE a.c_orgid=b.c_refid AND a.c_orgid=? AND a.c_active=true`),
|
||||
WHERE a.c_orgid=b.c_refid AND a.c_orgid=? AND a.c_active=`+s.IsTrue()),
|
||||
ctx.OrgID)
|
||||
|
||||
if err != sql.ErrNoRows && err != nil {
|
||||
|
@ -100,7 +100,7 @@ func (s Store) GetAccountsByOrg(ctx domain.RequestContext) (t []account.Account,
|
|||
|
||||
// CountOrgAccounts returns the numnber of active user accounts for specified organization.
|
||||
func (s Store) CountOrgAccounts(ctx domain.RequestContext) (c int) {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT count(*) FROM dmz_user_account WHERE c_orgid=? AND c_active=true"), ctx.OrgID)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT count(*) FROM dmz_user_account WHERE c_orgid=? AND c_active="+s.IsTrue()), ctx.OrgID)
|
||||
err := row.Scan(&c)
|
||||
if err == sql.ErrNoRows {
|
||||
return 0
|
||||
|
|
|
@ -223,29 +223,29 @@ func (s Store) GetSpaceCategorySummary(ctx domain.RequestContext, spaceID string
|
|||
c = []category.SummaryModel{}
|
||||
|
||||
err = s.Runtime.Db.Select(&c, s.Bind(`
|
||||
SELECT 'documents' AS type, c_categoryid AS categoryid, COUNT(*) AS count
|
||||
SELECT 'documents' AS grouptype, c_categoryid AS categoryid, COUNT(*) AS count
|
||||
FROM dmz_category_member
|
||||
WHERE c_orgid=? AND c_spaceid=?
|
||||
AND c_docid IN (
|
||||
SELECT c_refid
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_template=false AND c_groupid=''
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_template=`+s.IsFalse()+` AND c_groupid=''
|
||||
UNION ALL
|
||||
SELECT d.c_refid
|
||||
FROM (
|
||||
SELECT c_groupid, MIN(c_versionorder) AS latestversion
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_groupid!='' AND c_template=false
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_lifecycle!=2 AND c_groupid!='' AND c_template=`+s.IsFalse()+`
|
||||
GROUP BY c_groupid
|
||||
) AS x INNER JOIN dmz_doc AS d ON d.c_groupid=x.c_groupid AND d.c_versionorder=x.latestversion
|
||||
)
|
||||
GROUP BY c_categoryid, type
|
||||
GROUP BY c_categoryid, grouptype
|
||||
UNION ALL
|
||||
SELECT 'users' AS type, c_refid AS categoryid, count(*) AS count
|
||||
SELECT 'users' AS grouptype, c_refid AS categoryid, count(*) AS count
|
||||
FROM dmz_permission
|
||||
WHERE c_orgid=? AND c_location='category' AND c_refid IN
|
||||
(SELECT c_refid FROM dmz_category WHERE c_orgid=? AND c_spaceid=?)
|
||||
GROUP BY c_refid, type`),
|
||||
GROUP BY c_refid, grouptype`),
|
||||
ctx.OrgID, spaceID,
|
||||
ctx.OrgID, spaceID, ctx.OrgID, spaceID,
|
||||
ctx.OrgID, ctx.OrgID, spaceID)
|
||||
|
|
|
@ -80,7 +80,7 @@ func (s Store) GetBySpace(ctx domain.RequestContext, spaceID string) (documents
|
|||
c_lifecycle AS lifecycle, c_versioned AS versioned, c_versionid AS versionid,
|
||||
c_versionorder AS versionorder, c_groupid AS groupid, c_created AS created, c_revised AS revised
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_template=false AND c_spaceid IN
|
||||
WHERE c_orgid=? AND c_template=`+s.IsFalse()+` AND c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' AND c_refid=? AND c_refid IN
|
||||
(SELECT c_refid from dmz_permission WHERE c_orgid=? AND c_who='user' AND (c_whoid=? OR c_whoid='0') AND c_location='space' AND c_action='view'
|
||||
UNION ALL
|
||||
|
@ -113,7 +113,7 @@ func (s Store) TemplatesBySpace(ctx domain.RequestContext, spaceID string) (docu
|
|||
c_lifecycle AS lifecycle, c_versioned AS versioned, c_versionid AS versionid,
|
||||
c_versionorder AS versionorder, c_groupid AS groupid, c_created AS created, c_revised AS revised
|
||||
FROM dmz_doc
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_template=true AND c_lifecycle=1
|
||||
WHERE c_orgid=? AND c_spaceid=? AND c_template=`+s.IsTrue()+` AND c_lifecycle=1
|
||||
AND c_spaceid IN
|
||||
(SELECT c_refid FROM dmz_space WHERE c_orgid=? AND c_refid IN
|
||||
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' AND c_refid IN
|
||||
|
@ -144,7 +144,7 @@ func (s Store) PublicDocuments(ctx domain.RequestContext, orgID string) (documen
|
|||
SELECT d.c_refid AS documentid, d.c_name AS document, d.c_revised as revised, l.c_refid AS spaceid, l.c_name AS space
|
||||
FROM dmz_doc d
|
||||
LEFT JOIN dmz_space l ON l.c_refid=d.c_spaceid
|
||||
WHERE d.c_orgid=? AND l.c_type=1 AND d.c_lifecycle=1 AND d.c_template=false`),
|
||||
WHERE d.c_orgid=? AND l.c_type=1 AND d.c_lifecycle=1 AND d.c_template=`+s.IsFalse()),
|
||||
orgID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -94,7 +94,7 @@ func (s Store) GetPageLinks(ctx domain.RequestContext, documentID, pageID string
|
|||
func (s Store) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=true, c_revised=?
|
||||
c_orphan=`+s.IsTrue()+`, c_revised=?
|
||||
WHERE c_type='document' AND c_orgid=? AND c_targetdocid=?`),
|
||||
revised, ctx.OrgID, documentID)
|
||||
|
||||
|
@ -109,7 +109,7 @@ func (s Store) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID stri
|
|||
func (s Store) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=true, c_revised=?
|
||||
c_orphan=`+s.IsTrue()+`, c_revised=?
|
||||
WHERE c_type='section' AND c_orgid=? AND c_targetid=?`),
|
||||
revised, ctx.OrgID, pageID)
|
||||
|
||||
|
@ -124,7 +124,7 @@ func (s Store) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err
|
|||
func (s Store) MarkOrphanAttachmentLink(ctx domain.RequestContext, attachmentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
_, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc_link SET
|
||||
c_orphan=true, c_revised=?
|
||||
c_orphan=`+s.IsTrue()+`, c_revised=?
|
||||
WHERE c_type='file' AND c_orgid=? AND c_targetid=?`),
|
||||
revised, ctx.OrgID, attachmentID)
|
||||
|
||||
|
|
|
@ -86,11 +86,12 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_sub,`+s.EmptyJSON()+`) AS subscription,
|
||||
c_maxtags AS maxtags, c_created AS created, c_revised AS revised, c_theme AS theme
|
||||
FROM dmz_org
|
||||
WHERE c_domain=? AND c_active=true`),
|
||||
WHERE c_domain=? AND c_active=`+s.IsTrue()),
|
||||
subdomain)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
s.Runtime.Log.Error("meta", err)
|
||||
|
||||
// match on empty domain AS last resort
|
||||
err = s.Runtime.Db.Get(&o, s.Bind(`SELECT id, c_refid AS refid,
|
||||
|
@ -101,7 +102,7 @@ func (s Store) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
coalesce(c_sub,`+s.EmptyJSON()+`) AS subscription,
|
||||
c_maxtags AS maxtags, c_created AS created, c_revised AS revised, c_theme AS theme
|
||||
FROM dmz_org
|
||||
WHERE c_domain='' AND c_active=true`))
|
||||
WHERE c_domain='' AND c_active=`+s.IsTrue()))
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "unable to execute select for empty subdomain")
|
||||
|
@ -134,7 +135,7 @@ func (s Store) DeleteOrganization(ctx domain.RequestContext, orgID string) (rows
|
|||
|
||||
// RemoveOrganization sets the orgID organization to be inactive, thus executing a "soft delete" operation.
|
||||
func (s Store) RemoveOrganization(ctx domain.RequestContext, orgID string) (err error) {
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active=false WHERE c_refid=?"), orgID)
|
||||
_, err = ctx.Transaction.Exec(s.Bind("UPDATE dmz_org SET c_active="+s.IsFalse()+" WHERE c_refid=?"), orgID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute soft delete for org %s", orgID))
|
||||
|
@ -162,7 +163,7 @@ func (s Store) UpdateAuthConfig(ctx domain.RequestContext, org org.Organization)
|
|||
|
||||
// CheckDomain makes sure there is an organisation with the correct domain
|
||||
func (s Store) CheckDomain(ctx domain.RequestContext, domain string) string {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active=true"), domain)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT COUNT(*) FROM dmz_org WHERE c_domain=? AND c_active="+s.IsTrue()), domain)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
|
@ -179,7 +180,7 @@ func (s Store) CheckDomain(ctx domain.RequestContext, domain string) string {
|
|||
|
||||
// Logo fetchs stored image from store or NULL.
|
||||
func (s Store) Logo(ctx domain.RequestContext, domain string) (l []byte, err error) {
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT c_logo FROM dmz_org WHERE c_domain=? AND c_active=true"), domain)
|
||||
row := s.Runtime.Db.QueryRow(s.Bind("SELECT c_logo FROM dmz_org WHERE c_domain=? AND c_active="+s.IsTrue()), domain)
|
||||
|
||||
err = row.Scan(&l)
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -256,7 +256,7 @@ func (s Store) GetPageMeta(ctx domain.RequestContext, pageID string) (meta page.
|
|||
func (s Store) GetDocumentPageMeta(ctx domain.RequestContext, documentID string, externalSourceOnly bool) (meta []page.Meta, err error) {
|
||||
filter := ""
|
||||
if externalSourceOnly {
|
||||
filter = " AND c_external=true"
|
||||
filter = " AND c_external=" + s.IsTrue()
|
||||
}
|
||||
|
||||
err = s.Runtime.Db.Select(&meta, s.Bind(`SELECT id, c_sectionid AS sectionid,
|
||||
|
|
|
@ -165,7 +165,7 @@ func (s Store) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []us
|
|||
SELECT u.id, COALESCE(u.c_refid, '') AS refid, COALESCE(u.c_firstname, '') AS firstname, COALESCE(u.c_lastname, '') as lastname, u.email AS email, u.initials AS initials, u.password AS password, u.salt AS salt, u.c_reset AS reset, u.c_created AS created, u.c_revised AS revised
|
||||
FROM dmz_user u
|
||||
LEFT JOIN dmz_user_account a ON u.c_refid = a.c_userid
|
||||
WHERE a.c_orgid=? AND a.c_active=true AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND a.c_active=`+s.IsTrue()+` AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission
|
||||
WHERE c_orgid=? AND c_who='user' AND c_location='category' AND c_refid=?
|
||||
UNION ALL
|
||||
|
|
|
@ -14,6 +14,7 @@ package store
|
|||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -36,6 +37,8 @@ func (c *Context) Bind(sql string) string {
|
|||
switch c.Runtime.StoreProvider.Type() {
|
||||
case env.StoreTypePostgreSQL:
|
||||
bindParam = sqlx.DOLLAR
|
||||
case env.StoreTypeSQLServer:
|
||||
bindParam = sqlx.AT
|
||||
}
|
||||
|
||||
return sqlx.Rebind(bindParam, sql)
|
||||
|
@ -106,3 +109,13 @@ func (c *Context) EmptyJSON() string {
|
|||
func (c *Context) GetJSONValue(column, attribute string) string {
|
||||
return c.Runtime.StoreProvider.JSONGetValue(column, attribute)
|
||||
}
|
||||
|
||||
// IsTrue return string representation of TRUE for storage provider.
|
||||
func (c *Context) IsTrue() string {
|
||||
return c.Runtime.StoreProvider.IsTrue()
|
||||
}
|
||||
|
||||
// IsFalse return string representation of FALSE for storage provider.
|
||||
func (c *Context) IsFalse() string {
|
||||
return c.Runtime.StoreProvider.IsFalse()
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store"
|
||||
"github.com/documize/community/model/user"
|
||||
|
@ -153,7 +154,7 @@ func (s Store) GetActiveUsersForOrganization(ctx domain.RequestContext) (u []use
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=true
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=`+s.IsTrue()+`
|
||||
ORDER BY u.c_firstname, u.c_lastname`),
|
||||
ctx.OrgID)
|
||||
|
||||
|
@ -178,7 +179,8 @@ func (s Store) GetUsersForOrganization(ctx domain.RequestContext, filter string,
|
|||
likeQuery = " AND (LOWER(u.c_firstname) LIKE '%" + filter + "%' OR LOWER(u.c_lastname) LIKE '%" + filter + "%' OR LOWER(u.c_email) LIKE '%" + filter + "%') "
|
||||
}
|
||||
|
||||
err = s.Runtime.Db.Select(&u, s.Bind(`SELECT u.id, u.c_refid AS refid,
|
||||
if s.Runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
|
||||
err = s.Runtime.Db.Select(&u, s.Bind(`SELECT TOP(`+strconv.Itoa(limit)+`) u.id, u.c_refid AS refid,
|
||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
u.c_initials AS initials, u.c_globaladmin AS globaladmin,
|
||||
u.c_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||
|
@ -186,7 +188,18 @@ func (s Store) GetUsersForOrganization(ctx domain.RequestContext, filter string,
|
|||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? `+likeQuery+
|
||||
`ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(limit)), ctx.OrgID)
|
||||
`ORDER BY u.c_firstname, u.c_lastname`), ctx.OrgID)
|
||||
} else {
|
||||
err = s.Runtime.Db.Select(&u, s.Bind(`SELECT u.id, u.c_refid AS refid,
|
||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
u.c_initials AS initials, u.c_globaladmin AS globaladmin,
|
||||
u.c_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? `+likeQuery+
|
||||
`ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(limit)), ctx.OrgID)
|
||||
}
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
|
@ -210,7 +223,7 @@ func (s Store) GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []use
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=`+s.IsTrue()+` AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid=?
|
||||
UNION ALL
|
||||
SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid=?
|
||||
|
@ -236,22 +249,6 @@ func (s Store) GetUsersForSpaces(ctx domain.RequestContext, spaces []string) (u
|
|||
return
|
||||
}
|
||||
|
||||
// query, args, err := sqlx.In(s.Bind(`
|
||||
// SELECT u.id, u.c_refid AS refid,
|
||||
// u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
// u.c_initials AS initials, u.c_globaladmin AS globaladmin,
|
||||
// u.c_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||
// u.c_created AS created, u.c_revised AS revised,
|
||||
// a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
// FROM dmz_user u, dmz_user_account a
|
||||
// WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
// SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid IN(?)
|
||||
// UNION ALL
|
||||
// SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid IN(?)
|
||||
// )
|
||||
// ORDER BY u.c_firstname, u.c_lastname`),
|
||||
// ctx.OrgID, ctx.OrgID, spaces, ctx.OrgID, spaces)
|
||||
|
||||
query, args, err := sqlx.In(`
|
||||
SELECT u.id, u.c_refid AS refid,
|
||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
||||
|
@ -260,7 +257,7 @@ func (s Store) GetUsersForSpaces(ctx domain.RequestContext, spaces []string) (u
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=true AND u.c_refid IN (
|
||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=`+s.IsTrue()+` AND u.c_refid IN (
|
||||
SELECT c_whoid from dmz_permission WHERE c_orgid=? AND c_who='user' AND c_scope='object' AND c_location='space' AND c_refid IN(?)
|
||||
UNION ALL
|
||||
SELECT r.c_userid from dmz_group_member r LEFT JOIN dmz_permission p ON p.c_whoid=r.c_groupid WHERE p.c_orgid=? AND p.c_who='role' AND p.c_scope='object' AND p.c_location='space' AND p.c_refid IN(?)
|
||||
|
@ -333,7 +330,7 @@ func (s Store) ForgotUserPassword(ctx domain.RequestContext, email, token string
|
|||
|
||||
// CountActiveUsers returns the number of active users in the system.
|
||||
func (s Store) CountActiveUsers() (c []domain.SubscriptionUserAccount) {
|
||||
err := s.Runtime.Db.Select(&c, "SELECT c_orgid AS orgid, COUNT(*) AS users FROM dmz_user_account WHERE c_active=true GROUP BY c_orgid ORDER BY c_orgid")
|
||||
err := s.Runtime.Db.Select(&c, "SELECT c_orgid AS orgid, COUNT(*) AS users FROM dmz_user_account WHERE c_active="+s.IsTrue()+" GROUP BY c_orgid ORDER BY c_orgid")
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
s.Runtime.Log.Error("CountActiveUsers", err)
|
||||
|
@ -360,7 +357,7 @@ func (s Store) MatchUsers(ctx domain.RequestContext, text string, maxMatches int
|
|||
u.c_created AS created, u.c_revised AS revised,
|
||||
a.c_active AS active, a.c_editor AS editor, a.c_admin AS admin, a.c_users AS viewusers, a.c_analytics AS analytics
|
||||
FROM dmz_user u, dmz_user_account a
|
||||
WHERE a.c_orgid=? AND u.c_refid=a.c_userid AND a.c_active=true `+likeQuery+` ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(maxMatches)),
|
||||
WHERE a.c_orgid=? AND u.c_refid=a.c_userid AND a.c_active=`+s.IsTrue()+likeQuery+` ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(maxMatches)),
|
||||
ctx.OrgID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
|
@ -354,6 +354,16 @@ func (p MySQLProvider) ConvertTimestamp() (statement string) {
|
|||
return `STR_TO_DATE(?,'%Y-%m-%d %H:%i:%s')`
|
||||
}
|
||||
|
||||
// IsTrue returns "1"
|
||||
func (p MySQLProvider) IsTrue() string {
|
||||
return "1"
|
||||
}
|
||||
|
||||
// IsFalse returns "0"
|
||||
func (p MySQLProvider) IsFalse() string {
|
||||
return "0"
|
||||
}
|
||||
|
||||
// convertDatabaseVersion turns database version string as major,minor,patch numerics.
|
||||
func convertDatabaseVersion(v string) (ints []int, err error) {
|
||||
ints = []int{0, 0, 0}
|
||||
|
|
|
@ -295,3 +295,13 @@ func (p PostgreSQLProvider) VerfiyCharacterCollation(charset, collation string)
|
|||
func (p PostgreSQLProvider) ConvertTimestamp() (statement string) {
|
||||
return `to_timestamp(?,'YYYY-MM-DD HH24:MI:SS')`
|
||||
}
|
||||
|
||||
// IsTrue returns "true"
|
||||
func (p PostgreSQLProvider) IsTrue() string {
|
||||
return "true"
|
||||
}
|
||||
|
||||
// IsFalse returns "false"
|
||||
func (p PostgreSQLProvider) IsFalse() string {
|
||||
return "false"
|
||||
}
|
||||
|
|
|
@ -320,3 +320,13 @@ func (p SQLServerProvider) VerfiyCharacterCollation(charset, collation string) (
|
|||
func (p SQLServerProvider) ConvertTimestamp() (statement string) {
|
||||
return `convert(varchar, ?, 13)`
|
||||
}
|
||||
|
||||
// IsTrue returns "1"
|
||||
func (p SQLServerProvider) IsTrue() string {
|
||||
return "1"
|
||||
}
|
||||
|
||||
// IsFalse returns "0"
|
||||
func (p SQLServerProvider) IsFalse() string {
|
||||
return "0"
|
||||
}
|
||||
|
|
|
@ -71,6 +71,15 @@ let constants = EmberObject.extend({
|
|||
ReviewLabel: 'Changes require approval before publication'
|
||||
},
|
||||
|
||||
// Database type
|
||||
StorageProvider: { // eslint-disable-line ember/avoid-leaking-state-in-ember-objects
|
||||
SQLServer: 'SQLServer',
|
||||
PostgreSQL: 'PostgreSQL',
|
||||
Percona: 'Percona',
|
||||
MariaDB: 'MariaDB',
|
||||
MySQL: 'MySQL',
|
||||
},
|
||||
|
||||
// Document
|
||||
ApprovalType: { // eslint-disable-line ember/avoid-leaking-state-in-ember-objects
|
||||
None: 0,
|
||||
|
|
|
@ -37,10 +37,12 @@
|
|||
<i class={{concat "dicon " constants.Icon.Locked}} />
|
||||
<div class="name">Authentication</div>
|
||||
{{/link-to}}
|
||||
{{#link-to "customize.search" activeClass="selected" class="item" tagName="div"}}
|
||||
<i class={{concat "dicon " constants.Icon.Search}} />
|
||||
<div class="name">Search</div>
|
||||
{{/link-to}}
|
||||
{{#if (not-eq appMeta.storageProvider constants.StorageProvider.SQLServer)}}
|
||||
{{#link-to "customize.search" activeClass="selected" class="item" tagName="div"}}
|
||||
<i class={{concat "dicon " constants.Icon.Search}} />
|
||||
<div class="name">Search</div>
|
||||
{{/link-to}}
|
||||
{{/if}}
|
||||
{{#if (eq appMeta.edition constants.Product.EnterpriseEdition)}}
|
||||
{{#link-to "customize.audit" activeClass="selected" class="item" tagName="div"}}
|
||||
<i class={{concat "dicon " constants.Icon.ButtonAction}} />
|
||||
|
|
|
@ -32,7 +32,7 @@ type Member struct {
|
|||
|
||||
// SummaryModel holds number of documents and users for space categories.
|
||||
type SummaryModel struct {
|
||||
Type string `json:"type"` // documents or users
|
||||
GroupType string `json:"type"` // documents or users
|
||||
CategoryID string `json:"categoryId"`
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue