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

(add_recipient): Allow a recpt to be changed to a cc_recpt, and vice versa.

(find_recipient): New name for former is_recipient.  New API.  All
	callers updated.
parent 746cab29
/*
* $Id: text.c,v 0.34 1995/01/20 22:56:39 ceder Exp $
* $Id: text.c,v 0.35 1995/09/01 20:15:01 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* All atomic calls that deals with texts.
*/
static char *rcsid = "$Id: text.c,v 0.34 1995/01/20 22:56:39 ceder Exp $";
static char *rcsid = "$Id: text.c,v 0.35 1995/09/01 20:15:01 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -187,9 +187,10 @@ count_comment( Text_stat *t_stat )
* Check if CONF_NO is a recipient of the text whose text_stat is given.
*/
static Bool
is_recipient(Conf_no conf_no,
Text_stat * t_stat)
int
find_recipient(Conf_no conf_no,
Text_stat * t_stat)
{
int i;
......@@ -200,14 +201,14 @@ is_recipient(Conf_no conf_no,
case recpt:
if ( t_stat->misc_items[ i ].datum.recipient == conf_no )
{
return TRUE;
return i;
}
break;
case cc_recpt:
if ( t_stat->misc_items[ i ].datum.cc_recipient == conf_no )
{
return TRUE;
return i;
}
break;
......@@ -223,12 +224,12 @@ is_recipient(Conf_no conf_no,
#ifndef COMPILE_CHECKS
default:
restart_kom("is_recipient(): illegal misc_item\n");
restart_kom("find_recipient(): illegal misc_item\n");
#endif
}
}
return FALSE;
return -1;
}
......@@ -2174,6 +2175,7 @@ add_recipient( Text_no text_no,
{
Text_stat * t_stat;
Conference * conf_c;
int rcpt_index;
CHK_LOGIN(FAILURE);
GET_T_STAT(t_stat, text_no, FAILURE);
......@@ -2184,11 +2186,49 @@ add_recipient( Text_no text_no,
kom_errno = KOM_NO_SUCH_TEXT;
return FAILURE;
}
if ( is_recipient(conf_no, t_stat) )
rcpt_index = find_recipient(conf_no, t_stat);
if ( rcpt_index != -1 )
{
kom_errno = KOM_ALREADY_RECIPIENT;
return FAILURE;
/* You cannot add the same conference twice. */
if (t_stat->misc_items[rcpt_index].type == type)
{
kom_errno = KOM_ALREADY_RECIPIENT;
return FAILURE;
}
if (type != recpt && type != cc_recpt)
{
kom_errno = KOM_ILLEGAL_INFO_TYPE;
return FAILURE;
}
if (!is_supervisor(conf_no, conf_c, ACTPERS, ACT_P))
{
kom_errno = KOM_PERM;
return FAILURE;
}
/* Change a recpt to a cc_recpt or a cc_recpt to a recpt.
The ability to do this was introduced after a request
from Lisa Hallingstrom, who wanted to do this repeatedly
when managing the conference "Fragor och svar". */
t_stat->misc_items[rcpt_index].type = type;
#if 0
/* This should possibly be done, but differently.
ADD_MISC adds things lasts in the misc-info, and
that is not the correct thing to do. The change is
now performed silently instead. Also note that
these fields may already be present... FIXME. */
if ( t_stat->author != ACTPERS )
ADD_MISC(t_stat, sent_by, sender, ACTPERS);
ADD_MISC(t_stat, sent_at, sent_at, time(NULL));
#endif
mark_text_as_changed( text_no );
return OK;
}
if ( count_recipients( t_stat ) >= param.max_recipients )
......@@ -2267,7 +2307,7 @@ sub_recipient( Text_no text_no,
return FAILURE;
}
if ( !is_recipient( conf_no, text_s ) )
if (find_recipient(conf_no, text_s) == -1)
{
kom_errno = KOM_NOT_RECIPIENT;
return FAILURE;
......
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