Skip to content

Commit

Permalink
mxqadmin: Prevent groups that some group depends on to be reopened
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Aug 27, 2015
1 parent 1d79c0c commit e7c459b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mxqadmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,18 @@ static int update_group_flags_reopen(struct mx_mysql *mysql, uint64_t group_id,
struct mx_mysql_stmt *stmt = NULL;
unsigned long long num_rows = 0;
int res;
uint64_t flagsnottobeset;
uint64_t newflags = 0;

flagsnottobeset = MXQ_GROUP_FLAG_IS_DEPENDENCY;
newflags |= MXQ_GROUP_FLAG_CLOSED;

stmt = mx_mysql_statement_prepare(mysql,
"UPDATE mxq_group SET"
" group_flags = group_flags & ~(?)"
" WHERE group_id = ?"
" AND user_uid = ?"
" AND group_flags & ? = 0"
);
if (!stmt) {
mx_log_err("mx_mysql_statement_prepare(): %m");
Expand All @@ -136,6 +139,7 @@ static int update_group_flags_reopen(struct mx_mysql *mysql, uint64_t group_id,
res = mx_mysql_statement_param_bind(stmt, 0, uint64, &(newflags));
res += mx_mysql_statement_param_bind(stmt, 1, uint64, &(group_id));
res += mx_mysql_statement_param_bind(stmt, 2, uint32, &(user_uid));
res += mx_mysql_statement_param_bind(stmt, 3, uint64, &(flagsnottobeset));
assert(res == 0);

res = mx_mysql_statement_execute(stmt, &num_rows);
Expand Down

0 comments on commit e7c459b

Please sign in to comment.