mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +02:00
More SQL changes in line with new schema
This commit is contained in:
parent
944fd98421
commit
8ee63de6c7
14 changed files with 45 additions and 37 deletions
|
@ -82,6 +82,7 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error("unable to fetch user", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(u.Reset) > 0 || len(u.Password) == 0 {
|
if len(u.Reset) > 0 || len(u.Password) == 0 {
|
||||||
|
|
|
@ -134,7 +134,7 @@ func (s Scope) RemoveReference(ctx domain.RequestContext, id string) (err error)
|
||||||
func (s Scope) Update(ctx domain.RequestContext, b block.Block) (err error) {
|
func (s Scope) Update(ctx domain.RequestContext, b block.Block) (err error) {
|
||||||
b.Revised = time.Now().UTC()
|
b.Revised = time.Now().UTC()
|
||||||
_, err = ctx.Transaction.NamedExec(`UPDATE dmz_section_template SET
|
_, err = ctx.Transaction.NamedExec(`UPDATE dmz_section_template SET
|
||||||
c_name=:title, c_body=:body, c_desc=:excerpt, c_rawbody=:rawbody,
|
c_name=:name, c_body=:body, c_desc=:excerpt, c_rawbody=:rawbody,
|
||||||
c_config=:config, c_revised=:revised
|
c_config=:config, c_revised=:revised
|
||||||
WHERE c_orgid=:orgid AND c_refid=:refid`,
|
WHERE c_orgid=:orgid AND c_refid=:refid`,
|
||||||
b)
|
b)
|
||||||
|
|
|
@ -164,6 +164,7 @@ func (h *Handler) GetAll(w http.ResponseWriter, r *http.Request) {
|
||||||
cat, err := h.Store.Category.GetAllBySpace(ctx, spaceID)
|
cat, err := h.Store.Category.GetAllBySpace(ctx, spaceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error(method, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +250,7 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
cat, err := h.Store.Category.Get(ctx, catID)
|
cat, err := h.Store.Category.Get(ctx, catID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error(method, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,8 +320,8 @@ func (h *Handler) GetSummary(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
s, err := h.Store.Category.GetSpaceCategorySummary(ctx, spaceID)
|
s, err := h.Store.Category.GetSpaceCategorySummary(ctx, spaceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.Runtime.Log.Error("get space category summary failed", err)
|
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error(method, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,14 +77,14 @@ func (s Scope) GetAllBySpace(ctx domain.RequestContext, spaceID string) (c []cat
|
||||||
err = s.Runtime.Db.Select(&c, `
|
err = s.Runtime.Db.Select(&c, `
|
||||||
SELECT id, c_refid AS refid, c_orgid AS orgid, c_spaceid AS spaceid, c_name AS name, c_created AS created, c_revised AS revised
|
SELECT id, c_refid AS refid, c_orgid AS orgid, c_spaceid AS spaceid, c_name AS name, c_created AS created, c_revised AS revised
|
||||||
FROM dmz_category
|
FROM dmz_category
|
||||||
WHERE c_orgid=? AND c_spaceid=? AND spaceid IN
|
WHERE c_orgid=? AND c_spaceid=? AND c_spaceid IN
|
||||||
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' AND c_refid IN
|
(SELECT c_refid FROM dmz_permission WHERE c_orgid=? AND c_location='space' 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'
|
(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
|
UNION ALL
|
||||||
SELECT p.c_refid FROM dmz_permission p LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid
|
SELECT p.c_refid FROM dmz_permission p LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid
|
||||||
WHERE p.c_orgid=? AND p.c_who='role' AND p.c_location='space' AND p.c_action='view' AND (r.c_userid=? OR r.c_userid='0')
|
WHERE p.c_orgid=? AND p.c_who='role' AND p.c_location='space' AND p.c_action='view' AND (r.c_userid=? OR r.c_userid='0')
|
||||||
))
|
))
|
||||||
ORDER BY dmz_category`, ctx.OrgID, spaceID, ctx.OrgID, ctx.OrgID, ctx.UserID, ctx.OrgID, ctx.UserID)
|
ORDER BY c_name`, ctx.OrgID, spaceID, ctx.OrgID, ctx.OrgID, ctx.UserID, ctx.OrgID, ctx.UserID)
|
||||||
|
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
err = nil
|
err = nil
|
||||||
|
@ -108,7 +108,7 @@ func (s Scope) GetByOrg(ctx domain.RequestContext, userID string) (c []category.
|
||||||
SELECT p.c_refid FROM dmz_permission p LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid
|
SELECT p.c_refid FROM dmz_permission p LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid
|
||||||
WHERE p.c_orgid=? AND p.c_who='role' AND p.c_location='category' AND (r.c_userid=? OR r.c_userid='0')
|
WHERE p.c_orgid=? AND p.c_who='role' AND p.c_location='category' AND (r.c_userid=? OR r.c_userid='0')
|
||||||
))
|
))
|
||||||
ORDER BY dmz_category`, ctx.OrgID, ctx.OrgID, ctx.OrgID, userID, ctx.OrgID, userID)
|
ORDER BY c_name`, ctx.OrgID, ctx.OrgID, ctx.OrgID, userID, ctx.OrgID, userID)
|
||||||
|
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
err = nil
|
err = nil
|
||||||
|
|
|
@ -305,7 +305,7 @@ func (s Scope) Delete(ctx domain.RequestContext, documentID string) (rows int64,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return b.DeleteConstrained(ctx.Transaction, "document", ctx.OrgID, documentID)
|
return b.DeleteConstrained(ctx.Transaction, "dmz_doc", ctx.OrgID, documentID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteBySpace removes all documents for given space.
|
// DeleteBySpace removes all documents for given space.
|
||||||
|
|
|
@ -192,6 +192,7 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
g, err := h.Store.Group.Get(ctx, groupID)
|
g, err := h.Store.Group.Get(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error(method, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (s Scope) Add(ctx domain.RequestContext, g group.Group) (err error) {
|
||||||
// Get returns requested group.
|
// Get returns requested group.
|
||||||
func (s Scope) Get(ctx domain.RequestContext, refID string) (g group.Group, err error) {
|
func (s Scope) Get(ctx domain.RequestContext, refID string) (g group.Group, err error) {
|
||||||
err = s.Runtime.Db.Get(&g, `
|
err = s.Runtime.Db.Get(&g, `
|
||||||
SELECT id, c_refid AS refid, c_orgid AS orgid, c_name AS name, c_desc AS purpose, c_created, c_revised
|
SELECT id, c_refid AS refid, c_orgid AS orgid, c_name AS name, c_desc AS purpose, c_created AS created, c_revised AS revised
|
||||||
FROM dmz_group
|
FROM dmz_group
|
||||||
WHERE c_orgid=? AND c_refid=?`,
|
WHERE c_orgid=? AND c_refid=?`,
|
||||||
ctx.OrgID, refID)
|
ctx.OrgID, refID)
|
||||||
|
@ -63,8 +63,8 @@ func (s Scope) GetAll(ctx domain.RequestContext) (groups []group.Group, err erro
|
||||||
groups = []group.Group{}
|
groups = []group.Group{}
|
||||||
|
|
||||||
err = s.Runtime.Db.Select(&groups, `
|
err = s.Runtime.Db.Select(&groups, `
|
||||||
SELECT id, c_refid AS refid, c_orgid AS orgid, c_name AS name, c_desc AS purpose, c_created, c_revised
|
SELECT a.id, a.c_refid AS refid, a.c_orgid AS orgid, a.c_name AS name, a.c_desc AS purpose, a.c_created AS created, a.c_revised AS revised,
|
||||||
COUNT(b.groupid) AS members
|
COUNT(b.c_groupid) AS members
|
||||||
FROM dmz_group a
|
FROM dmz_group a
|
||||||
LEFT JOIN dmz_group_member b ON a.c_refid=b.c_groupid
|
LEFT JOIN dmz_group_member b ON a.c_refid=b.c_groupid
|
||||||
WHERE a.c_orgid=?
|
WHERE a.c_orgid=?
|
||||||
|
@ -101,7 +101,10 @@ func (s Scope) Update(ctx domain.RequestContext, g group.Group) (err error) {
|
||||||
// Delete removes group from store.
|
// Delete removes group from store.
|
||||||
func (s Scope) Delete(ctx domain.RequestContext, refID string) (rows int64, err error) {
|
func (s Scope) Delete(ctx domain.RequestContext, refID string) (rows int64, err error) {
|
||||||
b := mysql.BaseQuery{}
|
b := mysql.BaseQuery{}
|
||||||
b.DeleteConstrained(ctx.Transaction, "role", ctx.OrgID, refID)
|
_, err = b.DeleteConstrained(ctx.Transaction, "dmz_group", ctx.OrgID, refID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
return b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_group_member WHERE c_orgid=\"%s\" AND c_groupid=\"%s\"", ctx.OrgID, refID))
|
return b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_group_member WHERE c_orgid=\"%s\" AND c_groupid=\"%s\"", ctx.OrgID, refID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +133,7 @@ func (s Scope) GetGroupMembers(ctx domain.RequestContext, groupID string) (membe
|
||||||
|
|
||||||
// JoinGroup adds user to group.
|
// JoinGroup adds user to group.
|
||||||
func (s Scope) JoinGroup(ctx domain.RequestContext, groupID, userID string) (err error) {
|
func (s Scope) JoinGroup(ctx domain.RequestContext, groupID, userID string) (err error) {
|
||||||
_, err = ctx.Transaction.Exec("INSERT INTO dmz_group_member (orgid, groupid, userid) VALUES (?, ?, ?)", ctx.OrgID, groupID, userID)
|
_, err = ctx.Transaction.Exec("INSERT INTO dmz_group_member (c_orgid, c_groupid, c_userid) VALUES (?, ?, ?)", ctx.OrgID, groupID, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, "insert group member")
|
err = errors.Wrap(err, "insert group member")
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (s Scope) GetDocumentPages(ctx domain.RequestContext, documentID string) (p
|
||||||
SELECT id, c_refid AS refid, c_orgid AS orgid, c_docid AS documentid,
|
SELECT id, c_refid AS refid, c_orgid AS orgid, c_docid AS documentid,
|
||||||
c_userid AS userid, c_contenttype AS contenttype,
|
c_userid AS userid, c_contenttype AS contenttype,
|
||||||
c_type AS type, c_level AS level, c_sequence AS sequence, c_name AS name,
|
c_type AS type, c_level AS level, c_sequence AS sequence, c_name AS name,
|
||||||
c_body AS body, c_revisions AS revisions, c_blockid AS templateid,
|
c_body AS body, c_revisions AS revisions, c_templateid AS templateid,
|
||||||
c_status AS status, c_relativeid AS relativeid, c_created AS created, c_revised AS revised
|
c_status AS status, c_relativeid AS relativeid, c_created AS created, c_revised AS revised
|
||||||
FROM dmz_section
|
FROM dmz_section
|
||||||
WHERE c_docid=? AND (c_status=0 OR ((c_status=4 OR c_status=2) AND c_relativeid=''))`,
|
WHERE c_docid=? AND (c_status=0 OR ((c_status=4 OR c_status=2) AND c_relativeid=''))`,
|
||||||
|
|
|
@ -141,7 +141,7 @@ func (s Scope) GetCategoryPermissions(ctx domain.RequestContext, catID string) (
|
||||||
FROM dmz_permission
|
FROM dmz_permission
|
||||||
WHERE c_orgid=? AND c_location='category' AND c_who='user' AND (c_refid=? OR c_refid='0')
|
WHERE c_orgid=? AND c_location='category' AND c_who='user' AND (c_refid=? OR c_refid='0')
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT id, p.c_orgid AS orgid, p.c_who AS who, p.c_whoid AS whoid, p.c_action AS action, p.c_scope AS scope, p.c_location AS location, p.c_refid AS refid
|
SELECT p.id, p.c_orgid AS orgid, p.c_who AS who, p.c_whoid AS whoid, p.c_action AS action, p.c_scope AS scope, p.c_location AS location, p.c_refid AS refid
|
||||||
FROM dmz_permission p
|
FROM dmz_permission p
|
||||||
LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid
|
LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid
|
||||||
WHERE p.c_orgid=? AND p.c_location='category' AND p.c_who='role' AND (p.c_refid=? OR p.c_refid='0')`,
|
WHERE p.c_orgid=? AND p.c_location='category' AND p.c_who='role' AND (p.c_refid=? OR p.c_refid='0')`,
|
||||||
|
@ -163,7 +163,8 @@ func (s Scope) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []us
|
||||||
|
|
||||||
err = s.Runtime.Db.Select(&u, `
|
err = s.Runtime.Db.Select(&u, `
|
||||||
SELECT u.id, IFNULL(u.c_refid, '') AS refid, IFNULL(u.c_firstname, '') AS firstname, IFNULL(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
|
SELECT u.id, IFNULL(u.c_refid, '') AS refid, IFNULL(u.c_firstname, '') AS firstname, IFNULL(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
|
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=1 AND u.c_refid IN (
|
WHERE a.c_orgid=? AND a.c_active=1 AND u.c_refid IN (
|
||||||
SELECT c_whoid from dmz_permission
|
SELECT c_whoid from dmz_permission
|
||||||
WHERE c_orgid=? AND c_who='user' AND c_location='category' AND c_refid=?
|
WHERE c_orgid=? AND c_who='user' AND c_location='category' AND c_refid=?
|
||||||
|
|
|
@ -70,8 +70,8 @@ func (s Scope) GetByDomain(ctx domain.RequestContext, domain, email string) (u u
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised
|
u.c_created AS created, u.c_revised AS revised
|
||||||
FROM dmz_user u, dmz_account a, dmz_org o
|
FROM dmz_user u, dmz_user_account a, dmz_org o
|
||||||
WHERE TRIM(LOWER(u.c_email))=? AND u.c_refid=a.c_userid AND a.c_orgid=o.c_refid AND TRIM(LOWER(o.c_domain))=?`,
|
WHERE TRIM(LOWER(u.c_email))=? AND u.c_refid=a.c_userid AND a.c_orgid=o.c_refid AND TRIM(LOWER(o.c_domain))=?`,
|
||||||
email, domain)
|
email, domain)
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ func (s Scope) GetByEmail(ctx domain.RequestContext, email string) (u user.User,
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised
|
u.c_created AS created, u.c_revised AS revised
|
||||||
FROM dmz_user
|
FROM dmz_user u
|
||||||
WHERE TRIM(LOWER(c_email))=?`,
|
WHERE TRIM(LOWER(u.c_email))=?`,
|
||||||
email)
|
email)
|
||||||
|
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
|
@ -108,9 +108,9 @@ func (s Scope) GetByToken(ctx domain.RequestContext, token string) (u user.User,
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised
|
u.c_created AS created, u.c_revised AS revised
|
||||||
FROM dmz_user
|
FROM dmz_user u
|
||||||
WHERE c_reset=?`,
|
WHERE u.c_reset=?`,
|
||||||
token)
|
token)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -128,9 +128,9 @@ func (s Scope) GetBySerial(ctx domain.RequestContext, serial string) (u user.Use
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised
|
u.c_created AS created, u.c_revised AS revised
|
||||||
FROM dmz_user
|
FROM dmz_user u
|
||||||
WHERE c_salt=?`,
|
WHERE u.c_salt=?`,
|
||||||
serial)
|
serial)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -149,7 +149,7 @@ func (s Scope) GetActiveUsersForOrganization(ctx domain.RequestContext) (u []use
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised,
|
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
|
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
|
FROM dmz_user u, dmz_user_account a
|
||||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=1
|
WHERE u.c_refid=a.c_userid AND a.c_orgid=? AND a.c_active=1
|
||||||
|
@ -181,7 +181,7 @@ func (s Scope) GetUsersForOrganization(ctx domain.RequestContext, filter string,
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised,
|
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
|
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
|
FROM dmz_user u, dmz_user_account a
|
||||||
WHERE u.c_refid=a.c_userid AND a.c_orgid=? `+likeQuery+
|
WHERE u.c_refid=a.c_userid AND a.c_orgid=? `+likeQuery+
|
||||||
|
@ -206,7 +206,7 @@ func (s Scope) GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []use
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised,
|
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
|
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
|
FROM dmz_user u, dmz_user_account a
|
||||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=1 AND u.c_refid IN (
|
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=1 AND u.c_refid IN (
|
||||||
|
@ -240,7 +240,7 @@ func (s Scope) GetUsersForSpaces(ctx domain.RequestContext, spaces []string) (u
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised,
|
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
|
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
|
FROM dmz_user u, dmz_user_account a
|
||||||
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=1 AND u.c_refid IN (
|
WHERE a.c_orgid=? AND u.c_refid = a.c_userid AND a.c_active=1 AND u.c_refid IN (
|
||||||
|
@ -339,7 +339,7 @@ func (s Scope) MatchUsers(ctx domain.RequestContext, text string, maxMatches int
|
||||||
u.c_firstname AS firstname, u.c_lastname AS lastname, u.c_email AS email,
|
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_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_password AS password, u.c_salt AS salt, u.c_reset AS reset, u.c_lastversion AS lastversion,
|
||||||
u.c_created, u.c_revised,
|
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
|
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
|
FROM dmz_user u, dmz_user_account a
|
||||||
WHERE a.c_orgid=? AND u.c_refid=a.c_userid AND a.c_active=1 `+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=1 `+likeQuery+` ORDER BY u.c_firstname, u.c_lastname LIMIT `+strconv.Itoa(maxMatches),
|
||||||
|
|
|
@ -151,7 +151,7 @@ export default Component.extend(AuthProvider, ModalMixin, {
|
||||||
this.get('groupSvc')
|
this.get('groupSvc')
|
||||||
.update(group)
|
.update(group)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.load();
|
this.loadGroups();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.modalClose('#edit-group-modal');
|
this.modalClose('#edit-group-modal');
|
||||||
|
|
|
@ -204,7 +204,7 @@ export default Component.extend(AuthProvider, ModalMixin, TooltipMixin, {
|
||||||
// mark up groups user belongs to...
|
// mark up groups user belongs to...
|
||||||
let groups = this.get('groups');
|
let groups = this.get('groups');
|
||||||
groups.forEach((g) => {
|
groups.forEach((g) => {
|
||||||
let hasGroup = userGroups.findBy('roleId', g.get('id'));
|
let hasGroup = userGroups.findBy('groupId', g.get('id'));
|
||||||
g.set('isMember', is.not.undefined(hasGroup));
|
g.set('isMember', is.not.undefined(hasGroup));
|
||||||
})
|
})
|
||||||
this.set('groups', groups);
|
this.set('groups', groups);
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { computed } from '@ember/object';
|
||||||
|
|
||||||
export default Model.extend({
|
export default Model.extend({
|
||||||
orgId: attr('string'),
|
orgId: attr('string'),
|
||||||
roleId: attr('string'),
|
groupId: attr('string'),
|
||||||
userId: attr('string'),
|
userId: attr('string'),
|
||||||
|
|
||||||
// for UI only
|
// for UI only
|
||||||
|
|
|
@ -26,7 +26,7 @@ type Group struct {
|
||||||
type Member struct {
|
type Member struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
OrgID string `json:"orgId"`
|
OrgID string `json:"orgId"`
|
||||||
RoleID string `json:"roleId"`
|
GroupID string `json:"groupId"`
|
||||||
UserID string `json:"userId"`
|
UserID string `json:"userId"`
|
||||||
Firstname string `json:"firstname"` //read-only info
|
Firstname string `json:"firstname"` //read-only info
|
||||||
Lastname string `json:"lastname"` //read-only info
|
Lastname string `json:"lastname"` //read-only info
|
||||||
|
@ -36,7 +36,7 @@ type Member struct {
|
||||||
type Record struct {
|
type Record struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
OrgID string `json:"orgId"`
|
OrgID string `json:"orgId"`
|
||||||
RoleID string `json:"roleId"`
|
GroupID string `json:"groupId"`
|
||||||
UserID string `json:"userId"`
|
UserID string `json:"userId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Purpose string `json:"purpose"`
|
Purpose string `json:"purpose"`
|
||||||
|
@ -45,7 +45,7 @@ type Record struct {
|
||||||
// UserHasGroupMembership returns true if user belongs to specified group.
|
// UserHasGroupMembership returns true if user belongs to specified group.
|
||||||
func UserHasGroupMembership(r []Record, groupID, userID string) bool {
|
func UserHasGroupMembership(r []Record, groupID, userID string) bool {
|
||||||
for i := range r {
|
for i := range r {
|
||||||
if r[i].RoleID == groupID && r[i].UserID == userID {
|
if r[i].GroupID == groupID && r[i].UserID == userID {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func FilterGroupRecords(r []Record, groupID string) (m []Record) {
|
||||||
m = []Record{}
|
m = []Record{}
|
||||||
|
|
||||||
for i := range r {
|
for i := range r {
|
||||||
if r[i].RoleID == groupID {
|
if r[i].GroupID == groupID {
|
||||||
m = append(m, r[i])
|
m = append(m, r[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue