示例#1
0
static void formDeleteGroup(webs_t wp, char_t *path, char_t *query)
{
	char_t	*group, *ok;

	a_assert(wp);

	group = websGetVar(wp, T("group"), T("")); 
	ok = websGetVar(wp, T("ok"), T("")); 

	websHeader(wp);
	websMsgStart(wp);

	if (gstricmp(ok, T("ok")) != 0) {
		websWrite(wp, T("Delete Group Cancelled."));
	} else if ((group == NULL) || (*group == '\0')) {
		websWrite(wp, T("ERROR: No group was selected."));
	} else if (umGetGroupProtected(group)) {
		websWrite(wp, T("ERROR: Group, \"%s\" is delete-protected."), group);
	} else if (umGetGroupInUse(group)) {
		websWrite(wp, T("ERROR: Group, \"%s\" is being used."),	group);
	} else if (umDeleteGroup(group) != 0) {
		websWrite(wp, T("ERROR: Unable to delete group, \"%s\" "), group);
	} else {
		websWrite(wp, T("Group, \"%s\" was successfully deleted."), group);
	}

	websMsgEnd(wp);
	websFooter(wp);
	websDone(wp, 200);
}
示例#2
0
int	umDeleteGroup(char_t *group)
{
	int row;

	a_assert(group && *group);
	trace(3, T("UM: Deleting Group <%s>\n"), group);

/*
 *	Check to see if the group is in use
 */
	if (umGetGroupInUse(group)) {
		return UM_ERR_IN_USE;
	} 

/*
 *	Check to see if the group is delete-protected
 */
	if (umGetGroupProtected(group)) {
		return UM_ERR_PROTECTED;
	} 

/*
 *	Find the row of the group to delete
 */
	if ((row = dbSearchStr(didUM, UM_GROUP_TABLENAME, UM_NAME, group, 0)) < 0) {
		return UM_ERR_NOT_FOUND;
	}

	return dbDeleteRow(didUM, UM_GROUP_TABLENAME, row);
}