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

Fixed set_user_area and do_set_user_area (they were unaccessible

and untested before version 0.30).
parent 16a33e12
......@@ -158,50 +158,58 @@ do_mark_text(Pers_no pers_no,
static Success
do_set_user_area(Pers_no pers_no,
Person * pers_p,
Text_no text_no)
Person * pers_p, /* May be NULL */
Text_no user_area)
{
Text_stat * old_user_area;
Text_stat * new_user_area = NULL; /* To stop gcc complaining. */
/* Check that the new user_area exists before deleting the old */
/* Check that the new user_area exists before deleting the old*/
if ( text_no != 0 )
if ( user_area != 0 )
{
GET_T_STAT(new_user_area, text_no, FAILURE);
GET_T_STAT(new_user_area, user_area, FAILURE);
if ( new_user_area->no_of_marks >= MAX_MARKS_TEXT )
{
log("LIMIT: do_set_user_area(): New user_area very marked.\n");
log("LIMIT: set_user_area(%d, %d): New user_area's "
"mark count (%d) > %d.\n",
pers_no, user_area, new_user_area->no_of_marks,
MAX_MARKS_TEXT);
kom_errno = KOM_MARK_LIMIT;
return FAILURE;
}
}
if ( pers_p == NULL )
GET_P_STAT(pers_p, pers_no, FAILURE);
/* Unmark the previous user_area if it exists. */
if ( pers_p->user_area != 0
&& (old_user_area = cached_get_text_stat(text_no)) != NULL)
&& (old_user_area = cached_get_text_stat(pers_p->user_area)) != NULL)
{
if ( old_user_area->no_of_marks > 0 )
{
--old_user_area->no_of_marks;
mark_text_as_changed( text_no );
mark_text_as_changed( pers_p->user_area );
}
else
{
log("ERROR: do_set_user_area(): Old user_area not marked\n");
log("ERROR: set_user_area(%d, %d): Old user_area %d not marked\n",
pers_no, user_area, pers_p->user_area);
}
}
/* Mark the new user_area */
if ( text_no != 0 )
if ( user_area != 0 )
{
++new_user_area->no_of_marks;
mark_text_as_changed( text_no );
mark_text_as_changed( user_area );
}
pers_p->user_area = text_no;
mark_person_as_changed( pers_no );
pers_p->user_area = user_area;
mark_person_as_changed (pers_no);
return OK;
}
......@@ -643,20 +651,6 @@ set_passwd (Pers_no person,
return OK;
}
/*
* Set user_area. The text is a text which has previously been created
* with create_text(). It typically contains option-settings for the
* clients, e. g. if you want to be interrupted when new mail arrives.
* The format of this text is not yet defined.
*
* set_user_area(0) to clear the user area.
*/
Success
set_user_area(Text_no text_no)
{
return do_set_user_area(ACTPERS, ACT_P, text_no);
}
/*
* Ask which texts a person has read in a certain conference.
* Can be done before loggin. Will return EMPTY_MEMBERSHIP if VICTIM
......@@ -713,3 +707,30 @@ query_read_texts(Pers_no victim,
return OK;
}
/*
* Set user_area. The text is a text which has previously been created
* with create_text(). It typically contains option-settings for the
* clients, e. g. if you want to be interrupted when new mail arrives.
* The format of this text is not yet defined.
*
* set_user_area(0) to clear the user area.
*/
extern Success
set_user_area(Pers_no pers_no,
Text_no user_area)
{
Person *pers_p;
CHK_LOGIN(FAILURE);
GET_P_STAT(pers_p, pers_no, FAILURE);
if ( access_perm(pers_no, NULL) != unlimited )
{
kom_errno = KOM_PERM;
return FAILURE;
}
return do_set_user_area (pers_no, pers_p, user_area);
}
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