mirror of
https://github.com/haiwen/ccnet-server.git
synced 2025-08-30 19:32:25 +00:00
Add rpc for searching group by name
This commit is contained in:
parent
0f8c81a81d
commit
c1f9dcd7fe
@ -276,6 +276,10 @@ ccnet_start_rpc(CcnetSession *session)
|
||||
ccnet_rpc_set_group_creator,
|
||||
"set_group_creator",
|
||||
searpc_signature_int__int_string());
|
||||
searpc_server_register_function ("ccnet-threaded-rpcserver",
|
||||
ccnet_rpc_search_groups,
|
||||
"search_groups",
|
||||
searpc_signature_objlist__string_int_int());
|
||||
|
||||
searpc_server_register_function ("ccnet-threaded-rpcserver",
|
||||
ccnet_rpc_create_org,
|
||||
@ -776,6 +780,21 @@ ccnet_rpc_search_emailusers (const char *source,
|
||||
return emailusers;
|
||||
}
|
||||
|
||||
GList*
|
||||
ccnet_rpc_search_groups (const char *group_patt,
|
||||
int start, int limit,
|
||||
GError **error)
|
||||
{
|
||||
CcnetGroupManager *group_mgr =
|
||||
((CcnetServerSession *)session)->group_mgr;
|
||||
GList *groups = NULL;
|
||||
|
||||
groups = ccnet_group_manager_search_groups (group_mgr,
|
||||
group_patt,
|
||||
start, limit);
|
||||
return groups;
|
||||
}
|
||||
|
||||
GList*
|
||||
ccnet_rpc_search_ldapusers (const char *keyword,
|
||||
int start, int limit,
|
||||
|
@ -114,6 +114,11 @@ ccnet_rpc_search_emailusers (const char *source,
|
||||
const char *email_patt,
|
||||
int start, int limit,
|
||||
GError **error);
|
||||
GList*
|
||||
ccnet_rpc_search_groups (const char *group_patt,
|
||||
int start, int limit,
|
||||
GError **error);
|
||||
|
||||
|
||||
GList*
|
||||
ccnet_rpc_search_ldapusers (const char *keyword,
|
||||
|
@ -783,3 +783,61 @@ ccnet_group_manager_set_group_creator (CcnetGroupManager *mgr,
|
||||
|
||||
}
|
||||
|
||||
GList *
|
||||
ccnet_group_manager_search_groups (CcnetGroupManager *mgr,
|
||||
const char *keyword,
|
||||
int start, int limit)
|
||||
{
|
||||
CcnetDB *db = mgr->priv->db;
|
||||
GList *ret = NULL;
|
||||
int rc;
|
||||
char *db_patt = g_strdup_printf ("%%%s%%", keyword);
|
||||
|
||||
if (ccnet_db_type(db) == CCNET_DB_TYPE_PGSQL) {
|
||||
if (start == -1 && limit == -1)
|
||||
rc = ccnet_db_statement_foreach_row (db,
|
||||
"SELECT group_id, group_name, "
|
||||
"creator_name, timestamp "
|
||||
"FROM \"Group\" WHERE group_name LIKE ?",
|
||||
get_all_ccnetgroups_cb, &ret,
|
||||
1, "string", db_patt);
|
||||
|
||||
else
|
||||
rc = ccnet_db_statement_foreach_row (db,
|
||||
"SELECT group_id, group_name, "
|
||||
"creator_name, timestamp "
|
||||
"FROM \"Group\" WHERE group_name LIKE ? "
|
||||
"LIMIT ? OFFSET ?",
|
||||
get_all_ccnetgroups_cb, &ret,
|
||||
3, "string", db_patt,
|
||||
"int", limit, "int", start);
|
||||
} else {
|
||||
if (start == -1 && limit == -1)
|
||||
rc = ccnet_db_statement_foreach_row (db,
|
||||
"SELECT group_id, group_name, "
|
||||
"creator_name, timestamp "
|
||||
"FROM `Group` WHERE group_name LIKE ?",
|
||||
get_all_ccnetgroups_cb, &ret,
|
||||
1, "string", db_patt);
|
||||
else
|
||||
rc = ccnet_db_statement_foreach_row (db,
|
||||
"SELECT group_id, group_name, "
|
||||
"creator_name, timestamp "
|
||||
"FROM `Group` WHERE group_name LIKE ? "
|
||||
"LIMIT ? OFFSET ?",
|
||||
get_all_ccnetgroups_cb, &ret,
|
||||
3, "string", db_patt,
|
||||
"int", limit, "int", start);
|
||||
}
|
||||
g_free (db_patt);
|
||||
|
||||
if (rc < 0) {
|
||||
while (ret != NULL) {
|
||||
g_object_unref (ret->data);
|
||||
ret = g_list_delete_link (ret, ret);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_list_reverse (ret);
|
||||
}
|
||||
|
@ -107,5 +107,9 @@ ccnet_group_manager_set_group_creator (CcnetGroupManager *mgr,
|
||||
int group_id,
|
||||
const char *user_name);
|
||||
|
||||
GList*
|
||||
ccnet_group_manager_search_groups (CcnetGroupManager *mgr,
|
||||
const char *keyword,
|
||||
int start, int limit);
|
||||
#endif /* GROUP_MGR_H */
|
||||
|
||||
|
@ -327,6 +327,10 @@ class CcnetThreadedRpcClient(RpcClientBase):
|
||||
def set_group_creator(self, group_id, user_name):
|
||||
pass
|
||||
|
||||
@searpc_func("objlist", ["string", "int", "int"])
|
||||
def search_groups(self, group_patt, start, limit):
|
||||
pass
|
||||
|
||||
@searpc_func("int", ["string", "string", "string"])
|
||||
def create_org(self, org_name, url_prefix, creator):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user