Annotation of ETA/skills.php3, revision 1.13

1.1       frystyk     1: <script language="php">
1.7       frystyk     2: #
1.13    ! frystyk     3: #      @(#) $Id: skills.php3,v 1.12 1999/06/03 00:13:40 frystyk Exp $
1.7       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: 
1.1       frystyk    15: $this = 'skills.php3';
1.2       frystyk    16: require ('funcs.phi');
                     17: $domain = getDomain();
1.13    ! frystyk    18: $skills_forum = checkConfigFile($domain, 'config.phi', 'skillsList.php3');
1.2       frystyk    19: require ($domain.'config.phi');
1.1       frystyk    20: 
1.12      frystyk    21: $W3C_AUTHOR = "forum@w3.org";
1.13    ! frystyk    22: $W3C_DATE = '$Date: 1999/06/03 00:13:40 $';
1.12      frystyk    23: $W3C_TOP = '
                     24: '.render_help('Contacts', 'Contacts').' (either a single person or a group) can have
                     25: certain '.render_help('skills', 'Skills').' that make them capable of resolving issues.';
                     26: $W3C_BOTTOM = '';
                     27: $W3C_NAVBAR = render_navbar_top(array());
                     28: 
1.1       frystyk    29: # -------------------- redirect unqualified requests --------------------
                     30: 
                     31: if (empty($skills_id) && $submit != 'add' && $nextAction != 'add') {
1.4       eric       32:     header('Location: '. formatRef('skillsList.php3', array()));
1.1       frystyk    33:     exit;
                     34: }
                     35: 
1.5       eric       36: # ------- check user credentials for all types of state changing operations ------
                     37: 
1.7       frystyk    38: $auth_contacts_id = checkCredentials();
                     39: if (empty($auth_contacts_id))
1.13    ! frystyk    40:     return blowDodge("Unable to find contact $contact!");
1.7       frystyk    41: if ($pass_contacts_id != $auth_contacts_id) {
                     42:     requestCredentials();
                     43:     exit;
                     44: }
                     45: $skills_contact_id = $pass_contacts_id;
1.5       eric       46: 
1.1       frystyk    47: # -------------------- handle POST data --------------------
                     48: 
                     49: if (!empty($HTTP_POST_VARS)) {
                     50: 
1.11      frystyk    51:     if ($submit == "add") {
                     52: 
                     53:        # Find the right schema
                     54:        list($w3cdb, $result, $skills_schema) = schema_find($w3cdb, $skills_forum);
                     55:        if(!$skills_schema)
1.13    ! frystyk    56:            return blowDodge("Unable to find schema for forum $skills_forum!");
1.11      frystyk    57:     }
                     58: 
1.1       frystyk    59: # -------------------- add entry --------------------
                     60: 
1.7       frystyk    61:     if($submit  == "add") {
1.1       frystyk    62:        $query = "INSERT INTO skills (".
                     63: " skills.contact,".
1.11      frystyk    64: " skills.schema,".
1.7       frystyk    65: " skills.forum,".
1.1       frystyk    66: " skills.category,".
                     67: " skills.priority,".
                     68: " skills.state".
                     69: ") VALUES (".
1.7       frystyk    70: " \"$skills_contact_id\",".
1.11      frystyk    71: " \"$skills_schema\",".
                     72: " \"$skills_forum\",".
1.1       frystyk    73: " \"$skills_category\",".
                     74: " \"$skills_priority\",".
                     75: " \"$skills_state\")";
                     76:        list($w3cdb, $result, $skills_id) = getNewEntry($w3cdb, $query);
                     77:        if(!$result)
1.13    ! frystyk    78:            return blowDodge("insert failed with query ".$query."!");
1.1       frystyk    79:     } elseif ($submit == "update") {
                     80: 
                     81: # -------------------- update entry --------------------
                     82: 
                     83:        $query = "UPDATE skills SET".
1.7       frystyk    84: " skills.contact=\"$skills_contact_id\",".
1.1       frystyk    85: " skills.category=\"$skills_category\",".
                     86: " skills.priority=\"$skills_priority\",".
                     87: " skills.state=\"$skills_state\"".
                     88: " WHERE skills.id=$skills_id";
                     89:        list($w3cdb, $result) = makeQuery($w3cdb, $query);
                     90:        if(!$result)
1.13    ! frystyk    91:            return blowDodge("update failed with query ".$query."!");
1.1       frystyk    92:     } elseif ($submit == "delete") {
                     93: 
                     94: # -------------------- delete entry --------------------
                     95: 
                     96:        $query = "delete from skills where skills.id=".$skills_id;
                     97:        list($w3cdb, $result) = makeQuery($w3cdb, $query);
                     98:        if(!$result)
1.13    ! frystyk    99:            return blowDodge("delete failed with query ".$query."!");
1.8       frystyk   100:        header('Location: '. formatRef('skillsList.php3', array('pass_contacts_id'=>$pass_contacts_id)));
1.4       eric      101:        exit;
1.1       frystyk   102:     }
                    103: }
                    104: 
                    105: # -------------------- get table data --------------------
                    106: 
1.4       eric      107: if ($nextAction == 'add') {
1.12      frystyk   108:     $query = "SELECT contacts.realname,forums.path,forums.description FROM contacts,uris,forums WHERE uris.id=contacts.email AND contacts.id='$skills_contact_id' AND forums.id='$skills_forum'";
1.3       eric      109:     list($w3cdb, $result, $row) = getSingleRow($w3cdb, $query);
1.12      frystyk   110:     $forums_description = $row[2];
                    111:     $forums_path = $row[1];
1.3       eric      112: } else {
1.12      frystyk   113:     $query = "SELECT contacts.realname,skills.category,skills.priority,skills.state,contacts.id,forums.path,forums.description FROM skills,contacts,uris,forums WHERE contacts.id=skills.contact AND uris.id=contacts.email AND skills.id='$skills_id' AND forums.id=skills.forum";
1.3       eric      114:     list($w3cdb, $result, $row) = getSingleRow($w3cdb, $query);
1.13    ! frystyk   115:     $forums_description = stripslashes($row[6]);
1.12      frystyk   116:     $forums_path = $row[5];
1.3       eric      117: }
1.7       frystyk   118: 
1.13    ! frystyk   119: $contacts_realname = stripslashes($row[0]);
        !           120: $T_uris_uri = render('uris_uri', 0, 'text', $contacts_realname, 
1.7       frystyk   121:                     array('size'=>30, 'href'=>formatRef('contacts.php3', array('contacts_id'=>$skills_contact_id))));
1.12      frystyk   122: $T_forums_description = render('forums_description', 0, 'text', $forums_description, array('size'=>50, 'href'=>formatDomainRef('issuesList.php3', $forums_path, array())));
1.4       eric      123: $T_skills_category = render('skills_category', $editing, 'arrayList', $row[1], 
                    124:                            array('array' => addArrays(array(array(000 => "any"),$issues_categories))));
                    125: $T_skills_priority = render('skills_priority', $editing, 'arrayList', $row[2], 
                    126:                            array('array' => addArrays(array(array(000 => "any"),$issues_priorities))));
                    127: $T_skills_state = render('skills_state', $editing, 'arrayList', $row[3], 
                    128:                         array('array' => addArrays(array(array(000 => "any"),$issues_states))));
1.1       frystyk   129: 
                    130: # -------------------- pre templates --------------------
                    131: 
1.7       frystyk   132: $W3C_TITLE = render_title('Skill for Contact', $editing, $nextAction, $contacts_realname);
1.9       frystyk   133: include ($domain.'pre-template.tpl');
1.1       frystyk   134: 
                    135: # -------------------- render table (with form) --------------------
                    136: 
1.4       eric      137: $skills_hiddenFields = renderHidden('skills_id', $skills_id);
                    138: $skills_hiddenFields .= renderHidden('pass_contacts_id', $pass_contacts_id);
1.8       frystyk   139: $skills_hiddenFields .= renderHidden('title_modifier', $title_modifier);
1.1       frystyk   140: include ('skills_renderTable.phi');
                    141: 
                    142: # -------------------- post templates --------------------
                    143: 
1.9       frystyk   144: include ($domain.'post-template.tpl');
1.1       frystyk   145: </script>
                    146: </body>
                    147: </html>

Webmaster