Commit 46506076 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(do_set_user_area): Renamed a few local variables. Call

	async_new_user_area when the user area changes.
parent 5fbbff4f
/*
* $Id: person.c,v 0.74 2003/01/06 12:23:16 ceder Exp $
* $Id: person.c,v 0.75 2003/01/06 13:10:19 ceder Exp $
* Copyright (C) 1991-1999, 2001-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -74,6 +74,7 @@
#include "local-to-global.h"
#include "kom-memory.h"
#include "server-time.h"
#include "send-async.h"
BUGDECL;
......@@ -285,35 +286,36 @@ do_unmark_text(Pers_no pers_no,
static Success
do_set_user_area(Pers_no pers_no,
Person * pers_p, /* May be NULL */
Text_no user_area)
Text_no new_area)
{
Text_stat * old_user_area;
Text_stat * new_user_area = NULL; /* To stop gcc complaining. */
Text_no old_area;
Text_stat *old_stat;
Text_stat *new_stat = NULL; /* To stop gcc complaining. */
/* Check that the new user_area exists before deleting the old*/
if (user_area != 0)
if (new_area != 0)
{
GET_T_STAT(new_user_area, user_area, FAILURE);
GET_T_STAT(new_stat, new_area, FAILURE);
if (!text_read_access(active_connection, user_area, new_user_area)
if (!text_read_access(active_connection, new_area, new_stat)
&& !ENA(admin, 2)) /* OK -- In an RPC call */
{
kom_errno = KOM_NO_SUCH_TEXT;
err_stat = user_area;
err_stat = new_area;
return FAILURE;
}
if (new_user_area->no_of_marks >= param.max_marks_text)
if (new_stat->no_of_marks >= param.max_marks_text)
{
kom_log("LIMIT: set_user_area(%d, %lu): "
"New user_area's mark count (%d) > %d.\n",
pers_no,
(unsigned long)user_area,
new_user_area->no_of_marks,
(unsigned long)new_area,
new_stat->no_of_marks,
param.max_marks_text);
err_stat = user_area;
err_stat = new_area;
kom_errno = KOM_MARK_LIMIT;
return FAILURE;
}
......@@ -324,34 +326,37 @@ do_set_user_area(Pers_no pers_no,
/* Unmark the previous user_area if it exists. */
if (pers_p->user_area != 0
&& (old_user_area = cached_get_text_stat(pers_p->user_area)) != NULL)
old_area = pers_p->user_area;
if (old_area != 0 && (old_stat = cached_get_text_stat(old_area)) != NULL)
{
if (old_user_area->no_of_marks > 0)
if (old_stat->no_of_marks > 0)
{
--old_user_area->no_of_marks;
mark_text_as_changed(pers_p->user_area);
--old_stat->no_of_marks;
mark_text_as_changed(old_area);
}
else
{
kom_log("ERROR: set_user_area(%d, %lu): "
"Old user_area %lu unmarked.\n",
pers_no, (unsigned long)user_area,
(unsigned long)pers_p->user_area);
pers_no, (unsigned long)new_area,
(unsigned long)old_area);
}
}
/* Mark the new user_area */
if (user_area != 0)
if (new_area != 0)
{
++new_user_area->no_of_marks;
mark_text_as_changed(user_area);
++new_stat->no_of_marks;
mark_text_as_changed(new_area);
}
pers_p->user_area = user_area;
pers_p->user_area = new_area;
mark_person_as_changed(pers_no);
if (old_area != new_area)
async_new_user_area(pers_no, old_area, new_area);
return OK;
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment