1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * $Id: member.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
22 #include <exception.h>
30 void require_save(string|void a, string|void b) { _Persistence->require_save(a,b); }
36 * Initialize the member variables. This is only the array of groups.
48 * The function is called when the object is deleted and it
49 * calls each group then and removes the member from the group.
56 array groups = copy_value(aoGroups);
57 if ( arrayp(groups) ) {
59 foreach(groups, grp) {
67 * Get an array of groups of this member.
69 * @return the groups of the user
77 return copy_value(aoGroups);
81 * Set the groups for this user. Only trusted objects are able to call this
82 * function. In fact I am not sure if this is used at all.
84 * @param grps - list of groups of the user
88 set_groups(array grps)
90 if ( !_SECURITY->trust(CALLER) )
91 THROW("Unauthorized call to set_groups()", E_ACCESS);
92 aoGroups = copy_value(grps);
93 require_save(STORE_GROUP);
97 * join_group() should not be called - instead call group->add_member() !
98 * Invalid calls are checked. The add_member() function will call this
101 * @param grp - the group to join
105 join_group(object grp)
107 ASSERTINFO(IS_PROXY(grp),"Group is not a proxy !");
108 ASSERTINFO(_SECURITY->valid_group(CALLER) && grp->get_object() == CALLER,
109 "Invalid calling object in join_group()");
111 aoGroups += ({ grp });
112 require_save(STORE_GROUP);
117 * This function is called to remove a group from the list of groups.
118 * It should not be called directly. Instead the group has to be called to
119 * remove one of its members. Invalid calls are checked and thrown.
121 * @param grp - the group to leave
122 * @return successfully or not
125 bool leave_group(object grp)
127 ASSERTINFO(IS_PROXY(grp),"Group is not a proxy !");
128 ASSERTINFO(_SECURITY->valid_group(CALLER) && grp->get_object() == CALLER,
129 "Invalid calling object in join_group(): "+
130 master()->describe_object(CALLER));
131 aoGroups -= ({ grp });
132 require_save(STORE_GROUP);