MessageboardFactory._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2  *
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.
7  *
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.
12  *
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
16  *
17  * $Id: MessageboardFactory.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
18  */
19 inherit "/factories/ObjectFactory";
20 #include <classes.h>
21 #include <macros.h>
22 #include <events.h>
23 #include <access.h>
24 #include <database.h>
25 #include <attributes.h>
26 class MessageboardFactory : public ObjectFactory{
27 public:
28 
29 
30 
31 
32 
33 string get_identifier() { return "Messageboard.factory"; }
34 string get_class_name() { return "Messageboard"; }
35 int get_class_id() { return CLASS_MESSAGEBOARD; }
36 
37 /**
38  * The execute function - create a new instance of type "Object"
39  *
40  * @param mapping vars - variables like name and description
41  * @return the newly created object
42  */
43 object execute(mapping vars)
44 {
45  object obj;
46 
47  string name = vars["name"];
48  try_event(EVENT_EXECUTE, CALLER, obj);
49  if ( vars->transient ) {
50  if ( mappingp(vars->attributes) )
51  vars->attributes[OBJ_TEMP] = 1;
52  else
53  vars->attributes = ([ OBJ_TEMP : 1 ]);
54  }
55  obj = ::object_create(name, get_class_name(), 0,
56  vars["attributes"],
57  vars["attributesAcquired"],
58  vars["attributesLocked"],
59  vars["sanction"],
60  vars["sanctionMeta"]);
61 
62  if ( stringp(vars["description"]) )
63  obj->set_attribute(OBJ_DESC, vars["description"]);
64  object nntp = _Server->get_module("nntp");
65  if ( objectp(nntp) )
66  nntp->register_group(obj);
67  run_event(EVENT_EXECUTE, CALLER, obj);
68 }
69 
70 void test () {
71 }
72 
73 
74 };