[ Index ]
 

Code source de Phorum 5.1.25

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/include/admin/ -> newforum.php (source)

   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["vroot"] =$_POST["vroot"];
 160                  $forum_settings_inherit["parent_id"] =$_POST["parent_id"];
 161                  $forum_settings_inherit["inherit_id"] =$_POST["inherit_id"];
 162  
 163                  // don't inherit this settings
 164                  unset($forum_settings_inherit["message_count"]);
 165                  unset($forum_settings_inherit["thread_count"]);
 166                  unset($forum_settings_inherit["last_post_time"]);
 167  
 168                  // we don't need to save the master forum
 169                  unset($forum_settings_inherit[$inherit_id]);
 170                  $_POST =$forum_settings_inherit;
 171  
 172              } else {
 173                  $_POST["inherit_id"]="NULL";
 174                  unset($_POST["pub_perms"]);
 175                  unset($_POST["reg_perms"]);
 176              }
 177  
 178          }
 179  
 180          if(defined("PHORUM_EDIT_FORUM") || defined("PHORUM_DEFAULT_OPTIONS")){
 181  
 182              $forum_settings=$_POST;
 183  
 184              if(defined("PHORUM_DEFAULT_OPTIONS")){
 185                  // these two will not be set if no options were checked
 186                  if(empty($forum_settings["pub_perms"])) $forum_settings["pub_perms"] = 0;
 187                  if(empty($forum_settings["reg_perms"])) $forum_settings["reg_perms"] = 0;
 188                  $res=phorum_db_update_settings(array("default_forum_options" => $forum_settings));
 189              } else {
 190                  $res=phorum_db_update_forum($forum_settings);
 191              }
 192  
 193              // setting the current settings to all forums/folders inheriting from this forum/default settings
 194              $forum_inherit_settings =phorum_db_get_forums(false,false,false,intval($_POST["forum_id"]));
 195              foreach($forum_inherit_settings as $inherit_setting) {
 196                  $forum_settings["forum_id"] =$inherit_setting["forum_id"];
 197                  // We don't need to inherit this settings
 198                  unset($forum_settings["name"]);
 199                  unset($forum_settings["description"]);
 200                  unset($forum_settings["active"]);
 201                  unset($forum_settings["parent_id"]);
 202                  unset($forum_settings["inherit_id"]);
 203                  unset($forum_settings["message_count"]);
 204                  unset($forum_settings["thread_count"]);
 205                  unset($forum_settings["last_post_time"]);
 206  
 207                  $res_inherit =phorum_db_update_forum($forum_settings);
 208              }
 209  
 210          } else {
 211              if(isset($_POST['forum_id'])) {
 212                  unset($_POST['forum_id']);
 213              }
 214              $res=phorum_db_add_forum($_POST);
 215          }
 216  
 217          if($res){
 218              if($reload){
 219                  $url = $PHORUM["admin_http_path"]."?module=editforum&forum_id=$_POST[forum_id]";
 220              } else {
 221                  $url = $PHORUM["admin_http_path"]."?module=default&parent_id=$_POST[parent_id]";
 222              }
 223  
 224              phorum_redirect_by_url($url);
 225              exit();
 226          } else {
 227              $error="Database error while adding/updating forum.";
 228          }
 229      }
 230  
 231      foreach($_POST as $key=>$value){
 232          $$key=$value;
 233      }
 234      $pub_perms=0;
 235      if(isset($_POST["pub_perms"])) foreach($_POST["pub_perms"] as $perm=>$check){
 236          $pub_perms = $pub_perms | $perm;
 237      }
 238      $reg_perms=0;
 239      if(isset($_POST["reg_perms"])) foreach($_POST["reg_perms"] as $perm=>$check){
 240          $reg_perms = $reg_perms | $perm;
 241      }
 242  
 243  
 244  } elseif(defined("PHORUM_EDIT_FORUM")) {
 245  
 246      $forum_settings = phorum_db_get_forums($_REQUEST["forum_id"]);
 247      extract($forum_settings[$_REQUEST["forum_id"]]);
 248  
 249  } else {
 250  
 251      // this is either a new forum or we are editing the default options
 252      extract($PHORUM["default_forum_options"]);
 253  
 254  }
 255  
 256  if($error){
 257      phorum_admin_error($error);
 258  }
 259  
 260  include_once  "./include/admin/PhorumInputForm.php";
 261  
 262  $frm =& new PhorumInputForm ("", "post");
 263  
 264  if(defined("PHORUM_DEFAULT_OPTIONS")){
 265      $frm->hidden("module", "forum_defaults");
 266      $frm->hidden("forum_id", 0);
 267      $title="Default Forum Settings";
 268  } elseif(defined("PHORUM_EDIT_FORUM")){
 269      $frm->hidden("module", "editforum");
 270      $frm->hidden("forum_id", $forum_id);
 271      $title="Edit Forum";
 272  } else {
 273      $frm->hidden("module", "newforum");
 274      $title="Add A Forum";
 275  }
 276  
 277  $frm->addbreak($title);
 278  
 279  if(!defined("PHORUM_DEFAULT_OPTIONS")){
 280  
 281      $frm->addrow("Forum Title", $frm->text_box("name", $name, 30));
 282  
 283      $frm->addrow("Forum Description", $frm->textarea("description", $description, $cols=60, $rows=10, "style=\"width: 100%;\""), "top");
 284  
 285      $folder_list=phorum_get_folder_info();
 286      $frm->addrow("Folder", $frm->select_tag("parent_id", $folder_list, $parent_id));
 287      if($vroot > 0) {
 288          $frm->addrow("This folder is in the Virtual Root of:",$folder_list[$vroot]);
 289      }
 290  
 291  
 292      $frm->addrow("Visible", $frm->select_tag("active", array("No", "Yes"), $active));
 293  
 294      // Edit + inherit_id exists
 295      if(defined("PHORUM_EDIT_FORUM") && strlen($inherit_id)>0 ) {
 296  
 297          if($inherit_id!=0){
 298              $forum_settings_inherit = phorum_db_get_forums($inherit_id);
 299          }
 300          // inherit_forum not exists
 301          if( $inherit_id==0 || isset($forum_settings_inherit[$inherit_id]) ) {
 302              $disabled_form_input="disabled=\"disabled\"";
 303          } else {
 304              $inherit_id ="0";
 305              unset($forum_settings_inherit);
 306          }
 307      } else {
 308          unset($disabled_form_input);
 309      }
 310  
 311      $frm->addbreak("Inherit Forum Settings");
 312  
 313      $forum_list=phorum_get_forum_info(1);
 314  
 315      $forum_list["0"] ="Use Default Forum Settings";
 316      $forum_list["NULL"] ="None - I want to customize this forum's settings";
 317  
 318      // Remove this Forum
 319      if($forum_id>0){
 320          unset($forum_list[$forum_id]);
 321      }
 322  
 323      // Check for Slaves
 324      if( intval($forum_id) ) {
 325  
 326          $forum_inherit_settings=phorum_db_get_forums(false,false,false,intval($forum_id));
 327          if( count($forum_inherit_settings)>0 ) {
 328              $disabled_form_input_inherit="disabled=\"disabled\"";
 329          }
 330      }
 331  
 332      // set to NULL if inherit is disabled
 333      if($inherit_id=="" && $inherit_id!==0) $inherit_id="NULL";
 334  
 335      $row=$frm->addrow("Inherit Settings from Forum", $frm->select_tag("inherit_id", $forum_list, $inherit_id, $disabled_form_input_inherit));
 336  
 337      // Set Settings from inherit forum
 338      if( $forum_settings_inherit ) {
 339          $forum_settings =$forum_settings_inherit;
 340          extract($forum_settings[$inherit_id]);
 341      }
 342  }
 343  
 344  $frm->addbreak("Moderation / Permissions");
 345  
 346  $row=$frm->addrow("Moderate Messages", $frm->select_tag("moderation", array(PHORUM_MODERATE_OFF=>"Disabled", PHORUM_MODERATE_ON=>"Enabled"), $moderation, $disabled_form_input));
 347  
 348  $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.");
 349  
 350  $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));
 351  
 352  $pub_perm_frm = $frm->checkbox("pub_perms[".PHORUM_USER_ALLOW_READ."]", 1, "Read", $pub_perms & PHORUM_USER_ALLOW_READ, $disabled_form_input)."&nbsp;&nbsp;".
 353  $frm->checkbox("pub_perms[".PHORUM_USER_ALLOW_REPLY."]", 1, "Reply", $pub_perms & PHORUM_USER_ALLOW_REPLY, $disabled_form_input)."&nbsp;&nbsp;".
 354  $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 />".
 355  $frm->checkbox("pub_perms[".PHORUM_USER_ALLOW_ATTACH."]", 1, "Attach&nbsp;Files", $pub_perms & PHORUM_USER_ALLOW_ATTACH, $disabled_form_input);
 356  
 357  $frm->addrow("Public Users", $pub_perm_frm);
 358  
 359  $reg_perm_frm = $frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_READ."]", 1, "Read", $reg_perms & PHORUM_USER_ALLOW_READ, $disabled_form_input)."&nbsp;&nbsp;".
 360  $frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_REPLY."]", 1, "Reply", $reg_perms & PHORUM_USER_ALLOW_REPLY, $disabled_form_input)."&nbsp;&nbsp;".
 361  $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 />".
 362  $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;".
 363  $frm->checkbox("reg_perms[".PHORUM_USER_ALLOW_ATTACH."]", 1, "Attach&nbsp;Files", $reg_perms & PHORUM_USER_ALLOW_ATTACH, $disabled_form_input);
 364  
 365  $row=$frm->addrow("Registered Users", $reg_perm_frm);
 366  
 367  $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.");
 368  
 369  $frm->addbreak("Display Settings");
 370  
 371  $frm->addrow("Fixed Display-Settings (user can't override them)", $frm->select_tag("display_fixed", array("No", "Yes"), $display_fixed, $disabled_form_input));
 372  
 373  $frm->addrow("Template", $frm->select_tag("template", phorum_get_template_info(), $template, $disabled_form_input));
 374  
 375  $frm->addrow("Language", $frm->select_tag("language", phorum_get_language_info(), $language, $disabled_form_input));
 376  
 377  $frm->addrow("List Threads Expanded", $frm->select_tag("threaded_list", array("No", "Yes"), $threaded_list, $disabled_form_input));
 378  $frm->addrow("Read Threads Expanded", $frm->select_tag("threaded_read", array("No", "Yes"), $threaded_read, $disabled_form_input));
 379  $frm->addrow("Reverse Threading", $frm->select_tag("reverse_threading", array("No", "Yes"), $reverse_threading, $disabled_form_input));
 380  
 381  $frm->addrow("Move Threads On Reply", $frm->select_tag("float_to_top", array("No", "Yes"), $float_to_top, $disabled_form_input));
 382  
 383  $frm->addrow("Message List Length (Flat Mode)", $frm->text_box("list_length_flat", $list_length_flat, 10, false, false, $disabled_form_input));
 384  $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));
 385  
 386  $frm->addrow("Read Page Length", $frm->text_box("read_length", $read_length, 10, false, false, $disabled_form_input, $disabled_form_input));
 387  
 388  $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));
 389  
 390  $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));
 391  
 392  $frm->addbreak("Posting Settings");
 393  
 394  $frm->addrow("Check for Duplicates", $frm->select_tag("check_duplicate", array("No", "Yes"), $check_duplicate, $disabled_form_input));
 395  
 396  $frm->addrow("Allow Email Notification", $frm->select_tag("allow_email_notify", array("No", "Yes"), $allow_email_notify, $disabled_form_input));
 397  
 398  $frm->addbreak("Attachment Settings");
 399  
 400  $frm->addrow("Number Allowed (0 to disable)", $frm->text_box("max_attachments", $max_attachments, 10, false, false, $disabled_form_input));
 401  
 402  $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));
 403  
 404  require_once ('./include/upload_functions.php');
 405  $system_max_upload = phorum_get_system_max_upload();
 406  $max_size = phorum_filesize($system_max_upload[0]);
 407  
 408  $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));
 409  $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.");
 410  
 411  $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));
 412  
 413  $frm->show();
 414  
 415  ?>


Généré le : Thu Nov 29 12:22:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics