Main Page | Directories | File List | File Members

include/trackers_run/index.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: index.php 5447 2006-02-19 16:04:08Z yeupou $
00006 #
00007 #  Copyright 1999-2000 (c) The SourceForge Crew
00008 #  Copyright 2001-2002 (c) Laurent Julliard, CodeX Team, Xerox
00009 #
00010 #  Copyright 2002-2006 (c) Mathieu Roy <yeupou--gnu.org>
00011 #                          Yves Perrin <yves.perrin--cern.ch>
00012 #
00013 #
00014 # The Savane project is free software; you can redistribute it and/or
00015 # modify it under the terms of the GNU General Public License
00016 # as published by the Free Software Foundation; either version 2
00017 # of the License, or (at your option) any later version.
00018 #
00019 # The Savane project is distributed in the hope that it will be useful,
00020 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 # GNU General Public License for more details.
00023 #
00024 # You should have received a copy of the GNU General Public License
00025 # along with the Savane project; if not, write to the Free Software
00026 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00027 
00028 # This page does not give access to sober mode
00029 unset($sober);
00030 
00031 # No group, no item was passed
00032 if (!$group_id)
00033 {
00034   exit_no_group();
00035 }
00036 
00037 
00038   # Initialize the global data structure before anything else
00039   trackers_init($group_id);
00040 
00041   $project=project_get_object($group_id);
00042   $changed = false;
00043   $changes = array();
00044   unset($browse_preamble, $previous_form_bad_fields, $sober);
00045 
00046   switch ($func)
00047     {
00048 
00049     case 'search' :
00050       {
00051         # Form to do a search on the item database
00052 
00053         include '../include/trackers_run/search.php';
00054         break;
00055       }
00056 
00057     case 'digest' :
00058       {
00059         # Form to create an item digest: search item stage
00060 
00061         include '../include/trackers_run/digest.php';
00062         include '../include/trackers_run/browse.php';   
00063         break;
00064       }
00065 
00066     case 'digestselectfield' :
00067       {
00068         # Form to create an item digest: select field stage
00069 
00070         include '../include/trackers_run/digest.php';
00071         break;
00072       }
00073 
00074     case 'digestget' :
00075       {
00076         # Form to create an item digest: output
00077 
00078         include '../include/trackers_run/digest.php';
00079         break;
00080       }
00081 
00082     case 'browse' :
00083       {
00084         # Browse thru the bug database
00085         # (it also the Default)
00086 
00087         include '../include/trackers_run/browse.php';
00088         break;
00089       }
00090 
00091     case 'additem' :
00092       {
00093         # Form to add new item
00094 
00095         include '../include/trackers_run/add.php';
00096         break;
00097       }
00098 
00099     case 'detailitem' :
00100       {
00101         ### Show a bug already in the database, permitting to add comment
00102         ### or even modify.
00103 
00104         if (member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'2'))
00105           {
00106             dbg("Management/Technician rights, include mod.php");
00107             include '../include/trackers_run/mod.php';
00108           }
00109         else
00110           {
00111             dbg("No specific rights, include detail.php");
00112             include '../include/trackers_run/detail.php';
00113           }
00114         break;
00115       }
00116 
00117     case 'postadditem' :
00118       {
00119         ### Actually add in the database what was filled in the form
00120 
00121         # Check for duplicates
00122         if (!form_check($form_id))
00123           { exit_error(_("Exiting")); }
00124 
00125         # Get the list of bug fields used in the form
00126         $vfl = trackers_extract_field_list();
00127 
00128         # Data control layer
00129         $address = "";
00130         $item_id=trackers_data_create_item($group_id,$vfl,$address);
00131 
00132         if ($item_id)
00133           {
00134 
00135             # Attach new file if there is one
00136             if ($input_file != "none" && $input_file)
00137               {
00138                 $changed |= trackers_attach_file($item_id,
00139                                                  $group_id,
00140                                                  $input_file, 
00141                                                  $input_file_name, # 4
00142                                                  $input_file_type,
00143                                                  $input_file_size, # 6
00144                                                  $file_description,
00145                                                  $changes);
00146 
00147               }
00148             # Add new cc if any
00149             if ($add_cc && user_isloggedin())
00150               {
00151                 trackers_add_cc($item_id,
00152                                 $group_id,
00153                                 sane_post("add_cc"),
00154                                 sane_post("cc_comment"), # 4
00155                                 $changes);
00156               }
00157 
00158             # Originator Email:
00159             # "Email address of the person who submitted the item
00160             # (if different from the submitter field, add address to CC list)"
00161             # Only apply this behavior if the field is present and used
00162             $oe_field_name = "originator_email";
00163             if (trackers_data_is_used($oe_field_name))
00164               {
00165                 if  (($is_trackeradmin && trackers_data_is_showed_on_add_members($oe_field_name)) ||
00166                      (!$is_trackeradmin && trackers_data_is_showed_on_add($oe_field_name)) ||
00167                      (!user_isloggedin() && trackers_data_is_showed_on_add_nologin($oe_field_name))) 
00168                   {
00169                     # cannot be a registered user
00170                     if (validate_email(sane_post($oe_field_name)))
00171                       {
00172                         # must be different from the submitter field
00173                         $user=user_getid();
00174                         $submitter_email = db_result(db_query("SELECT email FROM user WHERE user_id=".$user),
00175                                                      0, 'email');
00176                         if (sane_post($oe_field_name) != $submitter_email)
00177                           {
00178                             trackers_add_cc($item_id,
00179                                             $group_id,
00180                                             sane_post($oe_field_name),
00181                                             "Originator Email",
00182                                             $changes);
00183                           }
00184                       }
00185                     else
00186                       {
00187                         fb(_("Originator E-mail is not valid, thus was not added to the Carbon-Copy list."), 1);
00188                       }
00189                   }
00190               }
00191 
00192             # Send an email to notify the user of the item update
00193             # (third arg of get_item_notification must be 0 for a first 
00194             # submission)
00195             list($additional_address, $sendall) = trackers_data_get_item_notification_info($item_id, ARTIFACT, 0);
00196             
00197             if ((trim($address) != "") && (trim($additional_address) != "")) 
00198               {
00199                 $address .= ", ";
00200               }
00201             $address .= $additional_address;
00202 
00203             trackers_mail_followup($item_id, $address);
00204                 
00205             form_clean($form_id);
00206 
00207           }
00208         else
00209           {
00210             # Some error occurred  
00211 
00212             # Missing mandatory field?
00213             # The relevant error message was supposedly properly produced by
00214             # trackers_data_create_item.
00215             # Reshow the same page
00216             if ($previous_form_bad_fields)
00217               {
00218                 form_clean($form_id);
00219                 include '../include/trackers_run/add.php';
00220                 break;
00221               }
00222 
00223             # Otherwise, that's odd and there's not much to do. 
00224             fb(_("Missing parameters, nothing added."), 1);
00225 
00226           }
00227 
00228         # show browse item page
00229         include '../include/trackers_run/browse.php';
00230         break;
00231       }
00232 
00233     case 'postmoditem' :
00234       {
00235 
00236          ### Actually add in the database what was filled in the form
00237          ### for a bug already in the database, reserved to item techn.
00238          ### or manager.
00239 
00240         if (member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'2'))
00241           {
00242             dbg("Techn. or Manager rights, make an update on almost every fields.");
00243             
00244             # Check for duplicates
00245             if (!form_check($form_id))
00246               { exit_error(_("Exiting")); }
00247 
00248             # Special case: we may be searching for an item, in that case
00249             # reprint the same page, plus search results.
00250             if ($depends_search || 
00251                 $reassign_change_project_search ||
00252                 $canned_response == "!multiple!" ||
00253                 $change_quotation_style)
00254               {
00255                 if ($depends_search)
00256                   {
00257                     fb(_("You provided search words to get a list of items this one may depends on. Below, in the section \"Dependencies\", you can now select the appropriate one(s) and submit the form."));
00258                   }
00259                 if ($reassign_change_project_search)
00260                   {
00261                     fb(_("You provided search words to get a list of project this item should maybe reassigned to. Below, in the section \"Reassign this item\", you can now select the appropriate project and submit the form."));
00262                   }
00263                 if ($canned_response == "!multiple!")
00264                   {
00265                     fb(_("You selected Multiple Canned Responses: you are free now to select the one you want to use to compose your answer."));
00266                   }
00267                 if ($change_quotation_style)
00268                   {
00269                     if ($change_quotation_style == _("Quoted, ready to be copied/pasted into your new comment")) 
00270                       {
00271                         $quotation_style = "quoted";
00272                         fb(_("Previous comments will now be printed in a copy/paste-friendly mode."));
00273                       }
00274                     else
00275                       {
00276                         $quotation_style = false;
00277                       }
00278                   }
00279 
00280                 include '../include/trackers_run/mod.php';
00281                 break;
00282               }
00283             
00284 
00285             # Get the list of bug fields used in the form
00286             $vfl = trackers_extract_field_list();
00287 
00288             #data control layer
00289             $address = "";
00290             $changed = trackers_data_handle_update($group_id,
00291                                                    $item_id,
00292                                                    sane_post("dependent_on_task"),
00293                                                    sane_post("dependent_on_bugs"), # 4
00294                                                    sane_post("dependent_on_support"),
00295                                                    sane_post("dependent_on_patch"), # 6
00296                                                    sane_post("canned_response"),
00297                                                    $vfl, # 8
00298                                                    $changes,
00299                                                    $address);
00300             
00301             # The update failed due to a missing field? Reprint it and squish
00302             # the rest of the action normally done
00303             if (!$changed && $previous_form_bad_fields)
00304               {
00305                 form_clean($form_id);
00306                 include '../include/trackers_run/mod.php';
00307                 break;
00308               }
00309 
00310             # Attach new file if there is one
00311             if ($input_file != "none" && $input_file)
00312               {
00313                 $changed |= trackers_attach_file($item_id,
00314                                                  $group_id,
00315                                                  $input_file, 
00316                                                  $input_file_name, # 4
00317                                                  $input_file_type,
00318                                                  $input_file_size, # 6
00319                                                  $file_description,
00320                                                  $changes);
00321               }
00322 
00323             # Add new cc if any
00324             if ($add_cc)
00325               {
00326                 # No notification needs to be sent when a cc is added,
00327                 # it is irrelevant to the item itself
00328                 trackers_add_cc($item_id,
00329                                 $group_id,
00330                                 sane_post("add_cc"),
00331                                 sane_post("cc_comment"), # 4
00332                                 sane_post("changes"));
00333               }
00334 
00335             # Update vote (will do the necessary checks itself)
00336             # Currently votes does not influence notifications
00337             # (that could harass developers)
00338             if (trackers_data_is_used("vote")) 
00339               {
00340                 trackers_votes_update($item_id,
00341                                       $group_id,
00342                                       sane_post("new_vote"));                 
00343               }
00344             
00345             if ($changed)
00346               {
00347                 # Check if we re supposed to send all modifications to an address
00348                 list($additional_address, $sendall) = trackers_data_get_item_notification_info($item_id, ARTIFACT, 1);
00349                 
00350                 if (($sendall == 1) && (trim($address) != "") && (trim($additional_address) != "")) 
00351                   {
00352                     $address .= ", ";
00353                   }
00354                 $address .= $additional_address;
00355                 trackers_mail_followup($item_id, $address,$changes);
00356               }
00357             
00358             # Finally handle reassignation of an entry. Why so late?
00359             # Because all the information entered by someone reassigning
00360             # the bug must be in the original report, and will be duplicated
00361             # in the new one.
00362             if ($reassign_change_project || ($reassign_change_artifact && ($reassign_change_artifact != ARTIFACT)))
00363               {
00364                 dbg("reassign item: reassign_change_project:$reassign_change_project, reassign_change_artifact:$reassign_change_artifact, ARTIFACT:".ARTIFACT);
00365                 trackers_data_reassign_item ($item_id,
00366                                              sane_post("reassign_change_project"),
00367                                              sane_post("reassign_change_artifact"));
00368               }
00369             
00370             form_clean($form_id);    
00371             
00372             # show browse item page, unless the user want to get back
00373             # to the 
00374             # same report, to make something else
00375             if (!$submitreturn) 
00376               {
00377                 include '../include/trackers_run/browse.php';
00378               }
00379             else
00380               {
00381                 unset($_POST, $_FILES, $form_id, $depends_search, $reassign_change_project_search, $add_cc, $input_file, $changed, $vfl, $details, $comment); 
00382                 $nocache = 1;
00383                 include '../include/trackers_run/mod.php';
00384               }
00385             
00386           }
00387         break;
00388       }
00389       
00390     case 'postaddcomment' :
00391       {
00392         ### Add a comment to a bug already in the database,
00393         ### these are the only changes an non member can make
00394 
00395         # Check for duplicates
00396         if (!form_check($form_id))
00397           { exit_error(_("Exiting")); }
00398 
00399         # Add a new comment if there is one
00400         if ($comment != '')
00401           {
00402             # For none project members force the comment type to None (100)
00403             trackers_data_add_history('details',htmlspecialchars($comment),'',$item_id,100);
00404 
00405             # YPE fix to trigger notifications in case of non member
00406             $changes['details']['add'] = stripslashes($comment);
00407             $changes['details']['type'] = 'None';
00408             $changed = true;
00409 
00410             fb(_("Comment added to item."));
00411           }
00412         
00413         # Attach new file if there is one
00414         if ($input_file != "none" && $input_file)
00415           {
00416             $changed |= trackers_attach_file($item_id,
00417                                              $group_id,
00418                                              $input_file, 
00419                                              $input_file_name, # 4
00420                                              $input_file_type,
00421                                              $input_file_size, # 6
00422                                              $file_description,
00423                                              $changes);
00424           }
00425         # Add new cc if any, only accepted from logged in users.
00426         if ($add_cc && user_isloggedin())
00427           {
00428             # No notification needs to be sent when a cc is added,
00429             # it is irrelevant to the item itself
00430             trackers_add_cc($item_id,
00431                             $group_id,
00432                             sane_post("add_cc"),
00433                             sane_post("cc_comment"), # 4
00434                             $changes);
00435           }
00436         
00437         # Add vote, if configured to be accepted from non members or if 
00438         # the user is member
00439         if (trackers_data_is_used("vote"))
00440           {
00441             if (trackers_data_is_showed_on_add("vote") && user_isloggedin() ||
00442                 member_check(user_getid(), $group_id))
00443               {
00444                 # Currently votes does not influence notifications
00445                 # (that could harass developers)
00446                 trackers_votes_update($item_id,
00447                                       $group_id,
00448                                       sane_post("new_vote"));   
00449               }
00450           }
00451         if ($changed)
00452           {
00453             list($additional_address, $sendall) = trackers_data_get_item_notification_info($item_id, ARTIFACT, 1);
00454             if (($sendall == 1) && (trim($address) != "") && (trim($additional_address) != "")) 
00455               {
00456                 $address .= ", ";
00457               }
00458             $address .= $additional_address;
00459             trackers_mail_followup($item_id, $address, $changes);
00460           }
00461             
00462         form_clean($form_id);
00463         
00464         include '../include/trackers_run/browse.php';
00465         break;
00466       }
00467 
00468     case 'delete_file' :
00469       {
00470         # Remove an attached file
00471 
00472         if (member_check(0,$group_id, member_create_tracker_flag(ARTIFACT).'2'))
00473           {
00474             trackers_data_delete_file($group_id,
00475                                       $item_id,
00476                                       sane_all("item_file_id"));
00477 
00478             # unset previous settings and return to the item
00479             unset($depends_search, $reassign_change_project_search, $add_cc, $input_file, $changed, $vfl, $details); 
00480             include '../include/trackers_run/mod.php';
00481           }
00482         else
00483           {
00484             exit_permission_denied();
00485           }
00486         break;
00487       }
00488 
00489     case 'delete_cc' :
00490       {
00491         #### Remove a person from the Cc: list of a bug
00492         $changed = trackers_delete_cc($group_id,
00493                                       $item_id,
00494                                       sane_all("item_cc_id"),
00495                                       $changes);
00496 
00497         # Irrevelant: no need to warn people that someone got retired from the
00498         # cc list.
00499 #       if ($changed)
00500 #         {
00501              # see if we're supposed to send all modifications to an address
00502 #            list($additional_address, $sendall) = trackers_data_get_item_notification_info($item_id, ARTIFACT, 1);
00503 #            if (($sendall == 1) && (trim($address) != "") && (trim($additional_address) != "")) 
00504 #{
00505 #               $address .= ", ";
00506 #             }
00507 #            $address .= $additional_address;
00508 #             trackers_mail_followup($item_id, $address,$changes);
00509 #           }
00510 
00511           # unset previous settings and return to the item
00512           unset($depends_search, $reassign_change_project_search, $add_cc, $input_file, $changed, $vfl, $details); 
00513           include '../include/trackers_run/mod.php';
00514 
00515           break;
00516         }
00517 
00518       case 'delete_dependancy' :
00519         {
00520           ### Remove a dependancy
00521 
00522           $changed |= trackers_delete_dependancy($group_id,
00523                                                 $item_id,
00524                                                 sane_all("item_depends_on"),
00525                                                 sane_all("item_depends_on_artifact"),
00526                                                 $changes);
00527 
00528           if ($changed)
00529             {
00530              # see if we're supposed to send all modifications to an address
00531             list($additional_address, $sendall) = trackers_data_get_item_notification_info($item_id, ARTIFACT, 1);
00532             if (($sendall == 1) && (trim($address) != "") && (trim($additional_address) != "")) 
00533               {
00534                 $address .= ", ";
00535               }
00536             $address .= $additional_address;
00537             trackers_mail_followup($item_id, $address,$changes);
00538           }
00539 
00540 
00541         # unset previous settings and return to the item
00542         unset($depends_search, $reassign_change_project_search, $add_cc, $input_file, $changed, $vfl, $details, $changes, $address);
00543         include '../include/trackers_run/mod.php';
00544 
00545         break;
00546       }
00547 
00548       /*
00549          Follow the code of filters (query form) modification.
00550          This is currently broken, due to the separation of personal
00551          and project-wide configuration.
00552 
00553          It will be reactivate, but maybe not in this index page.
00554 
00555     case 'modfilters' :
00556       {
00557       # Modification of the filters (query form)
00558 
00559         if (user_isloggedin())
00560           {
00561             include '../include/trackers_run/mod_filters.php';
00562             break;
00563           }
00564         else
00565           { exit_not_logged_in(); }
00566       }
00567 
00568     case 'postmodfilters' :
00569       {
00570         if (user_isloggedin())
00571           {
00572             include '../include/trackers_run/postmod_filters.php';
00573             include '../include/trackers_run/mod_filters.php';
00574             break;
00575           }
00576         else
00577           { exit_not_logged_in(); }
00578       }
00579       */
00580 
00581     default :
00582       {
00583         ### Browse thru the bug database
00584 
00585         include '../include/trackers_run/browse.php';
00586         break;
00587       }
00588 
00589     }
00590 
00591 
00592 ?>

Generated on Sun Feb 26 13:23:04 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4