mirror of
https://github.com/haiwen/ccnet-server.git
synced 2025-08-19 12:57:06 +00:00
Update check_group_staff(): parent group's staff is also child's staff.
This commit is contained in:
parent
a74e7654e4
commit
1722451fb5
@ -404,10 +404,28 @@ int ccnet_group_manager_create_org_group (CcnetGroupManager *mgr,
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_group_staff (CcnetDB *db, int group_id, const char *user_name)
|
check_group_staff (CcnetDB *db, int group_id, const char *user_name)
|
||||||
{
|
{
|
||||||
return ccnet_db_statement_exists (db, "SELECT group_id FROM GroupUser WHERE "
|
gboolean exists;
|
||||||
|
GString *sql = g_string_new("");
|
||||||
|
g_string_printf (sql, "SELECT path FROM GroupStructure WHERE group_id=?");
|
||||||
|
char *path = ccnet_db_statement_get_string (db, sql->str, 1, "int", group_id);
|
||||||
|
|
||||||
|
|
||||||
|
if (!path) {
|
||||||
|
exists = ccnet_db_statement_exists (db, "SELECT group_id FROM GroupUser WHERE "
|
||||||
"group_id = ? AND user_name = ? AND "
|
"group_id = ? AND user_name = ? AND "
|
||||||
"is_staff = 1",
|
"is_staff = 1",
|
||||||
2, "int", group_id, "string", user_name);
|
2, "int", group_id, "string", user_name);
|
||||||
|
} else {
|
||||||
|
g_string_printf (sql, "SELECT group_id FROM GroupUser WHERE "
|
||||||
|
"group_id IN (%s) AND user_name = ? AND "
|
||||||
|
"is_staff = 1", path);
|
||||||
|
exists = ccnet_db_statement_exists (db, sql->str,
|
||||||
|
1, "string", user_name);
|
||||||
|
}
|
||||||
|
g_string_free (sql, TRUE);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ccnet_group_manager_remove_group (CcnetGroupManager *mgr,
|
int ccnet_group_manager_remove_group (CcnetGroupManager *mgr,
|
||||||
|
Loading…
Reference in New Issue
Block a user