Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
 
3
////////////////////////////////////////////////////////////////////////////////
4
//                                                                            //
5
//   Copyright (C) 2006  Phorum Development Team                              //
6
//   http://www.phorum.org                                                    //
7
//                                                                            //
8
//   This program is free software. You can redistribute it and/or modify     //
9
//   it under the terms of either the current Phorum License (viewable at     //
10
//   phorum.org) or the Phorum License that was distributed with this file    //
11
//                                                                            //
12
//   This program is distributed in the hope that it will be useful,          //
13
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
14
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
15
//                                                                            //
16
//   You should have received a copy of the Phorum License                    //
17
//   along with this program.                                                 //
18
////////////////////////////////////////////////////////////////////////////////
19
 
20
if(!defined("PHORUM_ADMIN")) return;
21
 
22
include_once "./include/users.php";
23
include_once "./include/format_functions.php";
24
 
25
$error="";
26
 
27
if(count($_POST)){
28
 
29
    // set the defaults and check values
30
 
31
    foreach($_POST as $field=>$value){
32
 
33
        switch($field){
34
 
35
            case "name":
36
                if(empty($value) && $_POST["module"]!="forum_defaults"){
37
                    $error="Please fill in Title";
38
                }
39
                break;
40
 
41
            case "list_length_flat":
42
                $_POST[$field]=(int)$value;
43
                if(empty($_POST[$field])){
44
                    $_POST[$field]=30;
45
                }
46
                break;
47
 
48
            case "list_length_threaded":
49
                $_POST[$field]=(int)$value;
50
                if(empty($_POST[$field])){
51
                    $_POST[$field]=15;
52
                }
53
                break;
54
 
55
            case "read_length":
56
                $_POST[$field]=(int)$value;
57
                if(empty($_POST[$field])){
58
                    $_POST[$field]=10;
59
                }
60
                break;
61
 
62
            case "max_attachments":
63
                $_POST[$field]=(int)$value;
64
                if(empty($_POST[$field])){
65
                    $_POST["allow_attachment_types"]="";
66
                    $_POST["max_attachment_size"]=0;
67
                    $_POST["max_totalattachment_size"]=0;
68
                }
69
                break;
70
 
71
            case "max_attachment_size":
72
            case "max_totalattachment_size":
73
                $_POST[$field]=(int)$value;
74
                break;
75
 
76
            case "display_fixed":
77
                $_POST[$field]=(int)$value;
78
                break;
79
 
80
            case "pub_perms":
81
                $permission = 0;
82
                foreach($_POST["pub_perms"] as $perm=>$check){
83
                    $permission = $permission | $perm;
84
                }
85
 
86
                $_POST["pub_perms"]=$permission;
87
                break;
88
 
89
            case "reg_perms":
90
                $permission = 0;
91
                foreach($_POST["reg_perms"] as $perm=>$check){
92
                    $permission = $permission | $perm;
93
                }
94
 
95
                $_POST["reg_perms"]=$permission;
96
                break;
97
 
98
            case "inherit_id":
99
                if( $_POST['inherit_id'] !== NULL && $_POST["inherit_id"] != "NULL" && $_POST['inherit_id'] != 0) {
100
                    $forum_check_inherit =phorum_db_get_forums(intval($_POST["inherit_id"]));
101
                    if( $forum_check_inherit[$_POST["inherit_id"]]["inherit_id"] || ($_POST["inherit_id"]==$_POST["forum_id"]) ) {
102
                        $error="Settings can't be inherited by this forum, because this forum already inherits settings from another forum.";
103
                    }
104
                    if( $forum_check_inherit[$_POST["inherit_id"]]["inherit_id"] === 0) {
105
                        $error="Settings can't be inherited by this forum, because this forum already inherits the default settings";
106
                    }
107
                }
108
                break;
109
        }
110
 
111
        if($error) break;
112
 
113
 
114
    }
115
 
116
    if(empty($error)){
117
        unset($_POST["module"]);
118
 
119
        // handling vroots
120
        if($_POST['parent_id'] > 0) {
121
            $parent_folder=phorum_db_get_forums($_POST['parent_id']);
122
            if($parent_folder[$_POST['parent_id']]['vroot'] > 0) {
123
                $_POST['vroot']=$parent_folder[$_POST['parent_id']]['vroot'];
124
            }
125
        } else {
126
            $_POST['vroot']=0;
127
        }
128
 
129
        // if we received no perms, set them to 0 so they will get saved correctly.
130
 
131
        if(!isset($_POST['pub_perms']) || empty($_POST["pub_perms"])) $_POST["pub_perms"]=0;
132
        if(!isset($_POST['reg_perms']) || empty($_POST["reg_perms"])) $_POST["reg_perms"]=0;
133
 
134
        $old_settings_arr = phorum_db_get_forums($_POST["forum_id"]);
135
        $old_settings = array_shift($old_settings_arr);
136
 
137
        if($_POST["forum_id"] && $old_settings["inherit_id"]!==NULL && $_POST["inherit_id"]=="NULL"){
138
            $reload = true;
139
        }
140
 
141
        // inherit settings if we've set this and are not in the default forum options
142
        if( !defined("PHORUM_DEFAULT_OPTIONS") && $_POST["inherit_id"]!="NULL"  && $_POST['inherit_id'] !== NULL ) {
143
 
144
            // Load inherit forum settings
145
            if($_POST["inherit_id"]==0){
146
                $forum_settings_inherit[0]=$PHORUM["default_forum_options"];
147
            } else {
148
                $forum_settings_inherit = phorum_db_get_forums($_POST["inherit_id"]);
149
            }
150
 
151
            if( isset($forum_settings_inherit[$_POST["inherit_id"]]) ) {
152
 
153
                // slave settings
154
                $forum_settings_inherit=$forum_settings_inherit[$_POST["inherit_id"]];
155
                $forum_settings_inherit["forum_id"] =$_POST["forum_id"];
156
                $forum_settings_inherit["name"] =$_POST["name"];
157
                $forum_settings_inherit["description"] =$_POST["description"];
158
                $forum_settings_inherit["active"] =$_POST["active"];
159
                $forum_settings_inherit["parent_id"] =$_POST["parent_id"];
160
                $forum_settings_inherit["inherit_id"] =$_POST["inherit_id"];
161
 
162
                // don't inherit this settings
163
                unset($forum_settings_inherit["message_count"]);
164
                unset($forum_settings_inherit["thread_count"]);
165
                unset($forum_settings_inherit["last_post_time"]);
166
 
167
                // we don't need to save the master forum
168
                unset($forum_settings_inherit[$inherit_id]);
169
                $_POST =$forum_settings_inherit;
170
 
171
            } else {
172
                $_POST["inherit_id"]="NULL";
173
                unset($_POST["pub_perms"]);
174
                unset($_POST["reg_perms"]);
175
            }
176
 
177
        }
178
 
179
        if(defined("PHORUM_EDIT_FORUM") || defined("PHORUM_DEFAULT_OPTIONS")){
180
 
181
            $forum_settings=$_POST;
182
 
183
            if(defined("PHORUM_DEFAULT_OPTIONS")){
184
                // these two will not be set if no options were checked
185
                if(empty($forum_settings["pub_perms"])) $forum_settings["pub_perms"] = 0;
186
                if(empty($forum_settings["reg_perms"])) $forum_settings["reg_perms"] = 0;
187
                $res=phorum_db_update_settings(array("default_forum_options" => $forum_settings));
188
            } else {
189
                $res=phorum_db_update_forum($forum_settings);
190
            }
191
 
192
            // setting the current settings to all forums/folders inheriting from this forum/default settings
193
            $forum_inherit_settings =phorum_db_get_forums(false,false,false,intval($_POST["forum_id"]));
194
            foreach($forum_inherit_settings as $inherit_setting) {
195
                $forum_settings["forum_id"] =$inherit_setting["forum_id"];
196
                // We don't need to inherit this settings
197
                unset($forum_settings["name"]);
198
                unset($forum_settings["description"]);
199
                unset($forum_settings["active"]);
200
                unset($forum_settings["parent_id"]);
201
                unset($forum_settings["inherit_id"]);
202
                unset($forum_settings["message_count"]);
203
                unset($forum_settings["thread_count"]);
204
                unset($forum_settings["last_post_time"]);
205
 
206
                $res_inherit =phorum_db_update_forum($forum_settings);
207
            }
208
 
209
        } else {
210
 
211
            $res=phorum_db_add_forum($_POST);
212
        }
213
 
214
        if($res){
215
            if($reload){
216
                $url = $_SERVER['PHP_SELF']."?module=editforum&forum_id=$_POST[forum_id]";
217
            } else {
218
                $url = $_SERVER['PHP_SELF']."?module=default&parent_id=$_POST[parent_id]";
219
            }
220
 
221
            phorum_redirect_by_url($url);
222
            exit();
223
        } else {
224
            $error="Database error while adding/updating forum.";
225
        }
226
    }
227
 
228
    foreach($_POST as $key=>$value){
229
        $$key=$value;
230
    }
231
    $pub_perms=0;
232
    if(isset($_POST["pub_perms"])) foreach($_POST["pub_perms"] as $perm=>$check){
233
        $pub_perms = $pub_perms | $perm;
234
    }
235
    $reg_perms=0;
236
    if(isset($_POST["reg_perms"])) foreach($_POST["reg_perms"] as $perm=>$check){
237
        $reg_perms = $reg_perms | $perm;
238
    }
239
 
240
 
241
} elseif(defined("PHORUM_EDIT_FORUM")) {
242
 
243
    $forum_settings = phorum_db_get_forums($_REQUEST["forum_id"]);
244
    extract($forum_settings[$_REQUEST["forum_id"]]);
245
 
246
} else {
247
 
248
    // this is either a new forum or we are editing the default options
249
    extract($PHORUM["default_forum_options"]);
250
 
251
}
252
 
253
if($error){
254
    phorum_admin_error($error);
255
}
256
 
257
include_once "./include/admin/PhorumInputForm.php";
258
 
259
$frm =& new PhorumInputForm ("", "post");
260
 
261
if(defined("PHORUM_DEFAULT_OPTIONS")){
262
    $frm->hidden("module", "forum_defaults");
263
    $frm->hidden("forum_id", 0);
264
    $title="Default Forum Settings";
265
} elseif(defined("PHORUM_EDIT_FORUM")){
266
    $frm->hidden("module", "editforum");
267
    $frm->hidden("forum_id", $forum_id);
268
    $title="Edit Forum";
269
} else {
270
    $frm->hidden("module", "newforum");
271
    $title="Add A Forum";
272
}
273
 
274
$frm->addbreak($title);
275
 
276
if(!defined("PHORUM_DEFAULT_OPTIONS")){
277
 
278
    $frm->addrow("Forum Title", $frm->text_box("name", $name, 30));
279
 
280
    $frm->addrow("Forum Description", $frm->textarea("description", $description, $cols=60, $rows=10, "style=\"width: 100%;\""), "top");
281
 
282
    $folder_list=phorum_get_folder_info();
283
    $frm->addrow("Folder", $frm->select_tag("parent_id", $folder_list, $parent_id));
284
    if($vroot > 0) {
285
        $frm->addrow("This folder is in the Virtual Root of:",$folder_list[$vroot]);
286
    }
287
 
288
 
289
    $frm->addrow("Visible", $frm->select_tag("active", array("No", "Yes"), $active));
290
 
291
    // Edit + inherit_id exists
292
    if(defined("PHORUM_EDIT_FORUM") && strlen($inherit_id)>0 ) {
293
 
294
        if($inherit_id!=0){
295
            $forum_settings_inherit = phorum_db_get_forums($inherit_id);
296
        }
297
        // inherit_forum not exists
298
        if( $inherit_id==0 || isset($forum_settings_inherit[$inherit_id]) ) {
299
            $disabled_form_input="disabled=\"disabled\"";
300
        } else {
301
            $inherit_id ="0";
302
            unset($forum_settings_inherit);
303
        }
304
    } else {
305
        unset($disabled_form_input);
306
    }
307
 
308
    $frm->addbreak("Inherit Forum Settings");
309
 
310
    $forum_list=phorum_get_forum_info(true);
311
 
312
    $forum_list["0"] ="Use Default Forum Settings";
313
    $forum_list["NULL"] ="None - I want to customize this forum's settings";
314
 
315
    // Remove this Forum
316
    if($forum_id>0){
317
        unset($forum_list[$forum_id]);
318
    }
319
 
320
    // Check for Slaves
321
    if( intval($forum_id) ) {
322
 
323
        $forum_inherit_settings=phorum_db_get_forums(false,false,false,intval($forum_id));
324
        if( count($forum_inherit_settings)>0 ) {
325
            $disabled_form_input_inherit="disabled=\"disabled\"";
326
        }
327
    }
328
 
329
    // set to NULL if inherit is disabled
330
    if($inherit_id=="" && $inherit_id!==0) $inherit_id="NULL";
331
 
332
    $row=$frm->addrow("Inherit Settings from Forum", $frm->select_tag("inherit_id", $forum_list, $inherit_id, $disabled_form_input_inherit));
333
 
334
    // Set Settings from inherit forum
335
    if( $forum_settings_inherit ) {
336
        $forum_settings =$forum_settings_inherit;
337
        extract($forum_settings[$inherit_id]);
338
    }
339
}
340
 
341
$frm->addbreak("Moderation / Permissions");
342
 
343
$row=$frm->addrow("Moderate Messages", $frm->select_tag("moderation", array(PHORUM_MODERATE_OFF=>"Disabled", PHORUM_MODERATE_ON=>"Enabled"), $moderation, $disabled_form_input));
344
 
345
$frm->addhelp($row, "Moderate Messages", "This setting determines whether messages are visible to users immediately after they are posted.  If enabled, all messages will remain hidden until approved by a moderator.");
346
 
347
$frm->addrow("Email Messages To Moderators", $frm->select_tag("email_moderators", array(PHORUM_EMAIL_MODERATOR_OFF=>"Disabled", PHORUM_EMAIL_MODERATOR_ON=>"Enabled"), $email_moderators, $disabled_form_input));
348
 
349
$pub_perm_frm = $frm->checkbox("pub_perms[".PHORUM_USER_ALLOW_READ."]", 1, "Read", $pub_perms & PHORUM_USER_ALLOW_READ, $disabled_form_input)."&nbsp;&nbsp;".
350
$frm->checkbox("pub_perms[".PHORUM_USER_ALLOW_REPLY."]", 1, "Reply", $pub_perms & PHORUM_USER_ALLOW_REPLY, $disabled_form_input)."&nbsp;&nbsp;".
351
$frm->checkbox("pub_perms[".PHORUM_USER_ALLOW_NEW_TOPIC."]", 1, "Create&nbsp;New&nbsp;Topics", $pub_perms & PHORUM_USER_ALLOW_NEW_TOPIC, $disabled_form_input)."<br />".
352
$frm->checkbox("pub_perms[".PHORUM_USER_ALLOW_ATTACH."]", 1, "Attach&nbsp;Files", $pub_perms & PHORUM_USER_ALLOW_ATTACH, $disabled_form_input);
353
 
354
$frm->addrow("Public Users", $pub_perm_frm);
355
 
356
$reg_perm_frm = $frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_READ."]", 1, "Read", $reg_perms & PHORUM_USER_ALLOW_READ, $disabled_form_input)."&nbsp;&nbsp;".
357
$frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_REPLY."]", 1, "Reply", $reg_perms & PHORUM_USER_ALLOW_REPLY, $disabled_form_input)."&nbsp;&nbsp;".
358
$frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_NEW_TOPIC."]", 1, "Create&nbsp;New&nbsp;Topics", $reg_perms & PHORUM_USER_ALLOW_NEW_TOPIC, $disabled_form_input)."<br />".
359
$frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_EDIT."]", 1, "Edit&nbsp;Their&nbsp;Posts", $reg_perms & PHORUM_USER_ALLOW_EDIT, $disabled_form_input)."&nbsp;&nbsp;".
360
$frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_ATTACH."]", 1, "Attach&nbsp;Files", $reg_perms & PHORUM_USER_ALLOW_ATTACH, $disabled_form_input);
361
 
362
$row=$frm->addrow("Registered Users", $reg_perm_frm);
363
 
364
$frm->addhelp($row, "Registered Users", "These settings do not apply to users that are granted permissions directly via the user admin or via a group permissions.");
365
 
366
$frm->addbreak("Display Settings");
367
 
368
$frm->addrow("Fixed Display-Settings (user can't override them)", $frm->select_tag("display_fixed", array("No", "Yes"), $display_fixed, $disabled_form_input));
369
 
370
$frm->addrow("Template", $frm->select_tag("template", phorum_get_template_info(), $template, $disabled_form_input));
371
 
372
$frm->addrow("Language", $frm->select_tag("language", phorum_get_language_info(), $language, $disabled_form_input));
373
 
374
$frm->addrow("List Threads Expanded", $frm->select_tag("threaded_list", array("No", "Yes"), $threaded_list, $disabled_form_input));
375
$frm->addrow("Read Threads Expanded", $frm->select_tag("threaded_read", array("No", "Yes"), $threaded_read, $disabled_form_input));
376
$frm->addrow("Reverse Threading", $frm->select_tag("reverse_threading", array("No", "Yes"), $reverse_threading, $disabled_form_input));
377
 
378
$frm->addrow("Move Threads On Reply", $frm->select_tag("float_to_top", array("No", "Yes"), $float_to_top, $disabled_form_input));
379
 
380
$frm->addrow("Message List Length (Flat Mode)", $frm->text_box("list_length_flat", $list_length_flat, 10, false, false, $disabled_form_input));
381
$frm->addrow("Message List Length (Threaded Mode, Nr. of Threads)", $frm->text_box("list_length_threaded", $list_length_threaded, 10, false, false, $disabled_form_input));
382
 
383
$frm->addrow("Read Page Length", $frm->text_box("read_length", $read_length, 10, false, false, $disabled_form_input, $disabled_form_input));
384
 
385
$frm->addrow("Display IP Addresses <small>(note: admins always see it)</small>", $frm->select_tag("display_ip_address", array("No", "Yes"), $display_ip_address, $disabled_form_input));
386
 
387
$frm->addrow("Count views", $frm->select_tag("count_views", array(0 => "No", 1 => "Yes, show views added to subject", 2 => "Yes, show views as extra column"), $count_views, $disabled_form_input));
388
 
389
$frm->addbreak("Posting Settings");
390
 
391
$frm->addrow("Check for Duplicates", $frm->select_tag("check_duplicate", array("No", "Yes"), $check_duplicate, $disabled_form_input));
392
 
393
$frm->addrow("Allow Email Notification", $frm->select_tag("allow_email_notify", array("No", "Yes"), $allow_email_notify, $disabled_form_input));
394
 
395
$frm->addbreak("Attachment Settings");
396
 
397
$frm->addrow("Number Allowed (0 to disable)", $frm->text_box("max_attachments", $max_attachments, 10, false, false, $disabled_form_input));
398
 
399
$frm->addrow("Allowed Files (eg: gif;jpg;png, empty for any)", $frm->text_box("allow_attachment_types", $allow_attachment_types, 10, false, false, $disabled_form_input));
400
 
401
$php_limit = ini_get('upload_max_filesize')*1024;
402
$max_packetsize = phorum_db_maxpacketsize();
403
if ($max_packetsize == NULL) {
404
    $db_limit = $php_limit;
405
} else {
406
    $db_limit = $max_packetsize/1024*.6;
407
}
408
$max_size =  phorum_filesize(min($php_limit, $db_limit)*1024);
409
 
410
$row=$frm->addrow("Max File Size In kB ($max_size maximum)", $frm->text_box("max_attachment_size", $max_attachment_size, 10, false, false, $disabled_form_input));
411
$frm->addhelp($row, "Max File Size", "This is the maximum that one uploaded file can be.  If you see a maximum here, that is the maximum imposed by either your PHP installation, database server or both.  Leaving this field as 0 will use this maximum.");
412
 
413
$frm->addrow("Max cumulative File Size In kB (0 for unlimited)", $frm->text_box("max_totalattachment_size", $max_totalattachment_size, 10, false, false, $disabled_form_input));
414
 
415
$frm->show();
416
 
417
?>