Annotation of ETA/forums.php3, revision 1.11

1.1       frystyk     1: <script language="php">
                      2: #
1.11    ! frystyk     3: #      @(#) $Id: forums.php3,v 1.10 1999/06/29 16:49:12 frystyk Exp $
1.1       frystyk     4: #      
                      5: #      Copyright © 1995-1998 World Wide Web Consortium, (Massachusetts
                      6: #      Institute of Technology, Institut National de Recherche en
                      7: #      Informatique et en Automatique, Keio University). All Rights
                      8: #      Reserved. This program is distributed under the W3C's Software
                      9: #      Intellectual Property License. This program is distributed in the hope
                     10: #      that it will be useful, but WITHOUT ANY WARRANTY; without even the
                     11: #      implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
                     12: #      PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
                     13: #      details.
                     14: 
                     15: $this = 'forums.php3';
                     16: require ('funcs.phi');
                     17: $domain = getDomain();
1.7       frystyk    18: $this_forum = checkConfigFile($domain, 'config.phi', 'forumsList.php3');
1.1       frystyk    19: require ($domain.'config.phi');
                     20: 
1.5       frystyk    21: $W3C_AUTHOR = "forum@w3.org";
1.11    ! frystyk    22: $W3C_DATE = '$Date: 1999/06/29 16:49:12 $'; #'
1.5       frystyk    23: $W3C_TOP = '
                     24: '.render_help('Forums', 'Forums').' are organized in a news group manner where each forum can contain a
                     25: set of issues and/or one or more sub fora. However, this does not mean that
                     26: this is the only way to relate issues - there can be arbitrary relationships
                     27: between any issues as well as between any other document on the Web.';
                     28: $W3C_BOTTOM = '';
                     29: $W3C_NAVBAR = render_navbar_top(array());
                     30: 
1.1       frystyk    31: # -------------------- redirect unqualified requests --------------------
                     32: 
                     33: if (empty($forums_id) && $submit != 'add' && $nextAction != 'add') {
                     34:     header('Location: '. formatRef('forumsList.php3', array()));
                     35:     exit;
                     36: }
                     37: 
                     38: # ------- check user credentials for all types of state changing operations ------
                     39: 
1.8       frystyk    40: if ($editing==1 || !empty($HTTP_POST_VARS)) {
                     41:     $forums_contact = checkCredentials();
                     42:     if (empty($forums_contact))
                     43:         return blowDodge("Unable to find contact $contact!");
                     44: }
1.1       frystyk    45: 
                     46: # -------------------- handle POST data --------------------
                     47: 
                     48: # Check that we have at least one schema available 
                     49: if ($nextAction == 'add') {
                     50:     $query = "SELECT * FROM schemas LIMIT 1";
                     51:     list($w3cdb, $result) = makeQuery($w3cdb, $query);
                     52:     if(!mysql_num_rows($result))
1.7       frystyk    53:        return blowDodge("Must have at least one <a href=\"".formatRef('schemasList.php3', array())."\">schema</a> in order to create a forum!");
1.1       frystyk    54: }
                     55: 
                     56: 
                     57: if (!empty($HTTP_POST_VARS)) {
1.11    ! frystyk    58: 
        !            59:     # Make sure that the path is valid (of the form "foo/bar/")
        !            60:     if (!empty($forums_path)) {
        !            61:        if (ord($forums_path) == 47) {
        !            62:            $new_path = substr($forums_path, 1);
        !            63:            $forums_path = $new_path;
        !            64:        }
        !            65:        if (substr($forums_path, -1) != '/') $forums_path .= chr(47);
        !            66:     }
1.1       frystyk    67: 
                     68: # -------------------- add entry --------------------
                     69: 
                     70:     if($submit  == "add") {
                     71:        $query = "INSERT INTO forums (".
                     72: " forums.path,".
                     73: " forums.schema,".
                     74: " forums.contact,".
                     75: " forums.description".
                     76: ") VALUES (".
1.6       frystyk    77: " '".addslashes($forums_path)."',".
                     78: " $forums_schema,".
                     79: " $forums_contact,".
                     80: " '".addslashes($forums_description)."')";
1.1       frystyk    81:        list($w3cdb, $result, $forums_id) = getNewEntry($w3cdb, $query);
                     82:        if(!$result)
1.7       frystyk    83:            return blowDodge("insert failed with query ". $query."!");
1.1       frystyk    84:     } elseif ($submit == "update") {
                     85: 
                     86: # -------------------- update entry --------------------
                     87: 
                     88:        $query = "UPDATE forums SET".
1.6       frystyk    89: " forums.path='".addslashes($forums_path)."',".
                     90: " forums.description='".addslashes($forums_description)."'".
1.1       frystyk    91: " WHERE forums.id=$forums_id";
                     92:        list($w3cdb, $result) = makeQuery($w3cdb, $query);
                     93:        if(!$result)
1.7       frystyk    94:            return blowDodge("update failed with query ". $query."!");
1.1       frystyk    95:     } elseif ($submit == "delete") {
                     96: 
                     97: # -------------------- delete entry --------------------
                     98: 
                     99:        $query = "delete from forums where forums.id=".$forums_id;
                    100:        list($w3cdb, $result) = makeQuery($w3cdb, $query);
                    101:        if(!$result)
1.7       frystyk   102:            return blowDodge("delete failed with query ". $query."!");
1.1       frystyk   103:        header('Location: '. formatRef('forumsList.php3', array('pass_contacts_id'=>$pass_contacts_id)));
                    104:        exit;
                    105:     }
                    106: }
                    107: 
                    108: # -------------------- get table data --------------------
                    109: 
                    110: if ($nextAction == 'add') {
                    111:     $row[0] = $domain;
                    112: } else {
                    113:     $query = "SELECT forums.path,forums.schema,forums.contact,forums.description,contacts.id,contacts.realname,schemas.id,schemas.description FROM forums,contacts,schemas WHERE schemas.id=forums.schema AND contacts.id=forums.contact AND forums.id='$forums_id'";
                    114:     list($w3cdb, $result, $row) = getSingleRow($w3cdb, $query);
                    115: }
                    116: 
1.7       frystyk   117: $T_forums_path = render('forums_path', $editing, 'text', stripslashes($row[0]), array('size'=>50, 'href'=>formatDomainRef('issuesList.php3', $row[0], array())));
                    118: $schema_description = stripslashes($row[6]);
1.3       frystyk   119: $T_forums_schema = render('forums_schema', $nextAction == 'add' ? $editing : 0, 'queryList', $row[7],
1.7       frystyk   120:                          array('w3cdb'=>$w3cdb, 'table'=>'schemas', 'index'=>'id', 'label'=>'description', 'href'=>formatRef('schemas.php3', array('schemas_id'=>$schema_description))));
                    121: $contacts_realname = stripslashes($row[5]);
                    122: $T_forums_contact = render('forums_contact', 0, 'text', $contacts_realname, array('size'=>30, 'href'=>formatRef('contacts.php3', array('contacts_id'=>$row[4]))));
                    123: $forums_description = stripslashes($row[3]);
                    124: $T_forums_description = render('forums_description', $editing, 'textarea', $forums_description, array('rows'=>10, 'cols'=>70));
1.1       frystyk   125: 
                    126: # -------------------- pre templates --------------------
                    127: 
                    128: $W3C_TITLE = render_title('Forum', $editing, $nextAction, $forums_description);
                    129: include ($domain.'pre-template.tpl');
                    130: 
                    131: # -------------------- render table (with form) --------------------
                    132: 
                    133: $skills_hiddenFields = renderHidden('forums_id', $forums_id);
                    134: $skills_hiddenFields .= renderHidden('pass_contacts_id', $pass_contacts_id);
                    135: $skills_hiddenFields .= renderHidden('title_modifier', $title_modifier);
                    136: include ('forums_renderTable.phi');
                    137: 
                    138: # -------------------- post templates --------------------
                    139: 
                    140: include ($domain.'post-template.tpl');
                    141: </script>
                    142: </body>
                    143: </html>

Webmaster