Main Page | Directories | File List | File Members

confirmation.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: confirmation.php 5474 2006-02-22 14:12:47Z yeupou $
00006 #
00007 #  Copyright 1999-2000 (c) The SourceForge Crew
00008 #  Copyright 2000-2003 (c) Free Software Foundation
00009 #                          Mathieu Roy <yeupou--gnu.org>
00010 #
00011 #  Copyright 2004-2006 (c) Mathieu Roy <yeupou--gnu.org>
00012 #
00013 # The Savane project is free software; you can redistribute it and/or
00014 # modify it under the terms of the GNU General Public License
00015 # as published by the Free Software Foundation; either version 2
00016 # of the License, or (at your option) any later version.
00017 #
00018 # The Savane project is distributed in the hope that it will be useful,
00019 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 # GNU General Public License for more details.
00022 #
00023 # You should have received a copy of the GNU General Public License
00024 # along with the Savane project; if not, write to the Free Software
00025 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00026 
00027 define("ARTIFACT", "task");
00028 require "../include/pre.php";
00029 session_require(array('isloggedin'=>'1'));
00030 require "../include/vars.php";
00031 
00032 $project=project_get_object($group_id);
00033 if ($show_confirm && $rand_hash)
00034 {
00035   # Forgot to select the group type
00036   if ($group_type == 100) 
00037     {
00038       exit_error(_("No group type has been selected. Use the back button."));
00039     }
00040 
00041   $HTML->header(array('title'=>_("Final Step: Confirmation")));
00042   $sql="UPDATE groups SET type='$group_type' WHERE group_id='$group_id' AND rand_hash='__$rand_hash'";
00043   $result=db_query($sql);
00044 
00045   $sql="SELECT * FROM groups WHERE group_id='$group_id' AND rand_hash='__$rand_hash'";
00046   $result=db_query($sql);
00047 
00048   print '
00049 <h2>'._("Final Step: Confirmation").'</h2>
00050 <div align="center"><span class="warn">'._("Do not click the back button").'</span></div>
00051 
00052 <form action="'.$PHP_SELF.'" method="post">
00053 <input type="hidden" name="no_redirection" value="1" />
00054 <input type="hidden" name="group_id" value="'.$group_id.'" />
00055 <input type="hidden" name="rand_hash" value="'.$rand_hash.'" />
00056 
00057 <h5>'._("Description:").'</h5>
00058 <textarea name="form_purpose" wrap="virtual" cols="70" rows="15">'.db_result($result,0,'register_purpose').'</textarea>
00059 
00060 <h5>'._("Other Software Required:").'</h5>
00061 <textarea name="form_required_sw" wrap="virtual" cols="70" rows="6">'.db_result($result,0,'required_software').'</textarea>
00062 
00063 <h5>'._("Other Comments:").'</h5>
00064 <textarea name="form_comments" wrap="virtual" cols="70" rows="4">'.db_result($result,0,'other_comments').'</textarea>
00065 
00066 <h5>'._("Full Name:").'</h5>
00067 <input size="40" maxlength="40" type="text" name="form_full_name" value="'.db_result($result,0,'group_name').'" />
00068 
00069 <h5>'._("System Name:").'</h5>'
00070     . db_result($result,0,'unix_group_name')
00071     . '
00072 <h5>'._("Project Type").':</h5>
00073    ';
00074   print show_group_type_box('group_type',$group_type);
00075   print '
00076 <h5>'._("License").':</h5>
00077 <select name="form_license">
00078    ';
00079 
00080   while (list($k,$v) = each($LICENSE))
00081     {
00082       print "<option value=\"$k\"";
00083       if ($k==db_result($result,0,'license'))
00084         {
00085           print ' selected';
00086         }
00087       print ">$v</option>\n";
00088     }
00089   print '</select>';
00090   print '
00091 <h5>'._("Other License:").'</h5>
00092 <textarea name="form_license_other" wrap="virtual" cols="60" rows="10">'
00093     . db_result($result,0,'license_other') . '</textarea>
00094 <p>'
00095     ._("If you confirm it, your project registration will be saved, waiting for a system administrator to approve it. If you reject it, this registration will be discarded.").'
00096 </p>
00097 <div class="center">
00098 <input type="submit" name="i_agree" value="'
00099     ._("Confirm").'">
00100 <input type="submit" name="i_disagree" value="'
00101     ._("Reject").'">
00102 </div>
00103 </form>';
00104 
00105   $HTML->footer(array());
00106 
00107 }
00108 else if ($i_agree && $group_id && $rand_hash)
00109 {
00110   # complete the db entries
00111   $result=db_query("UPDATE groups SET status='P', "
00112                    .    "register_purpose='".htmlspecialchars($form_purpose)."', "
00113                    .    "required_software='".htmlspecialchars($form_required_sw)."', "
00114                    .    "other_comments='".htmlspecialchars($form_comments)."', "
00115                    .    "group_name='$form_full_name', license='$form_license', "
00116                    .    "license='".htmlspecialchars($form_license)."', "
00117                    .    "license_other='".htmlspecialchars($form_license_other)."', "
00118                    .    "type='".htmlspecialchars($group_type)."'"
00119                    .    "WHERE group_id='$group_id' AND rand_hash='__$rand_hash'");
00120 
00121   if (db_affected_rows($result) < 1)
00122     {
00123       exit_error(_("Unable to update database, please contact administrators"));
00124     }
00125 
00126   # make the current user an admin
00127   $result = member_add(user_getid(), $group_id, "A");
00128 
00129   # admin    bugs  forums
00130   if (!$result)
00131     {
00132       exit_error(_("Setting you as project admin failed"));
00133     }
00134 
00135   $user_realname = user_getrealname(user_getid());
00136   $user_email = user_getemail(user_getid());
00137   $unix_name = group_getunixname($group_id);
00138   $sql_type = db_query("SELECT name FROM group_type WHERE type_id='$group_type'");
00139   $type = db_result($sql_type,0,'name');
00140   $type_base_host = $project->getTypeBaseHost();
00141   $type_admin_email_address = $project->getTypeAdminEmailAddress();
00142 
00143   # get site-specific content. It will define confirmation_gen_email()
00144   utils_get_content("register/confirmation_mail");
00145 
00146   $message = confirmation_gen_email ($type_base_host, $user_realname, $user_email, $type_admin_email_address, $form_license, $form_license_other, $form_full_name, $unix_name, $type, $form_purpose, $form_required_sw, $form_comments);
00147 
00148   $message_user = "$message"
00149      ."\n\n\n\n"
00150      ."*"._("In case you have to register your project again").".\n\n"
00151      .sprintf(_("Please be aware that if your registration does not fulfill all the requirements, the %s administrators may ask you to register your project again."),$GLOBALS['sys_name'])
00152      ._("You can use the following URL to do a new registration starting with the values used in this registration process.")."\n"
00153      ._("Copy and paste AS ONE SINGLE URL the following content:")."\n"
00154      ."----RERegistration-URL-BEGIN-----\n"
00155      ."http://".$project->getTypeBaseHost().$GLOBALS['sys_home']."register/basicinfo.php?re_purpose=".rawurlencode($form_purpose)."&re_require_sw=".rawurlencode($form_required_sw)."&re_comments=".rawurlencode($form_comments)."&re_full_name=".rawurlencode($form_full_name)."&re_unix_name=".rawurlencode($unix_name)."\n"
00156      ."----RERegistration-URL-END-------\n";
00157 
00158   $message_admin = "A new project has been registered at ".$GLOBALS['sys_name']." 
00159 The project account will remain inactive until a site admin approve or discard the registration.
00160 
00161 
00162 == REGISTRATION ADMINISTRATION ==
00163 
00164 While this item will be useful to track the registration process, approving or discarding the registration must be done using the specific \"Group Administration\" page, accessible only to site administrators, effectively logged as site administrators (superuser):
00165 
00166   <".$GLOBALS['sys_https_url'].$GLOBALS['sys_home']."siteadmin/groupedit.php?group_id=".$group_id.">
00167 
00168 
00169 == REGISTRATION DETAILS ==
00170 
00171 Full Name:
00172 ----------
00173   *".$form_full_name."*
00174 
00175 System Group Name:
00176 -----------------
00177   *".$unix_name."*
00178 
00179 Type:
00180 -----
00181   ".$type."
00182 
00183 License:
00184 -------- 
00185   ".$LICENSE[$form_license]."\n\n";
00186 
00187   if ($form_license_other) {
00188     $message_admin .= "Other License: 
00189 --------------
00190   ".$form_license_other."\n\n";
00191   }
00192 
00193 $message_admin .= "Description:
00194 ------------
00195   ".$form_purpose."\n\n";
00196 
00197  if ($form_required_sw) {
00198    $message_admin .= "Other Software Required:
00199 ------------------------
00200   ".$form_required_sw."\n\n";
00201  }
00202  
00203  if ($form_comments) {
00204    $message_admin .= "Other Comments:
00205 ---------------
00206   ".$form_comments."\n\n";
00207  }
00208  
00209   # a mail for the submitter
00210   sendmail_mail($type_admin_email_address,
00211                 $user_email,
00212                 "submission of $form_full_name - $type_base_host",
00213                 $message_user,
00214                 0,0,0,
00215                 $type_admin_email_address);
00216 
00217 
00218   # a mail for the moderators staff!
00219 # Done automatically by the task tracker
00220 #  sendmail_mail($user_email,
00221 #               $type_admin_email_address,
00222 #               "submission of $form_full_name - $type_base_host",
00223 #               $message_admin,
00224 #               0,0,0,
00225 #               $user_email);
00226 
00227   # special case: the unix_group_name fit the sys_unix_group_name:
00228   #   this project must be activated.
00229   if ($GLOBALS['sys_group_id'] == $group_id)
00230     {
00231       db_query("UPDATE groups SET status='A' WHERE group_id='$group_id' AND rand_hash='__$rand_hash'");
00232       # We also add a specific field for the task tracker
00233       # (we need to copy the None field)
00234       db_query("INSERT INTO task_field_value (bug_field_id,group_id,value_id,value,description,order_id,status) VALUES (103,$group_id,100,'None','',10,'P')");
00235       db_query("INSERT INTO task_field_value (bug_field_id,group_id,value_id,value,description,order_id,status) VALUES (103,$group_id,1,'Project Approval','Pending project registration',11,'P')");
00236       # We also need to make the task tracker post restriction of comment
00237       # accepting posting from logged-in users, otherwise they wont be able
00238       # to comment their registration
00239       db_query("INSERT INTO groups_default_permissions (group_id,task_rflags) VALUES ($group_id,300)");
00240     }
00241   else
00242     {
00243       require_directory("trackers");
00244       trackers_init($GLOBALS['sys_group_id']);
00245 
00246       # Otherwise, create a new item on the admin task tracker
00247       # (planned close date: 10 days later)
00248       $vfl = array();
00249       $vfl['category_id'] = '1';
00250       $vfl['summary'] = 'Submission of '.$form_full_name;
00251       $vfl['details'] = $message_admin; 
00252       $vfl['planned_starting_date'] = date("Y")."-".date("m")."-".date("d");
00253       $vfl['planned_close_date'] = date("Y")."-".date("m")."-".(date("d")+10);
00254         
00255       $address = "";
00256       $item_id = trackers_data_create_item($GLOBALS['sys_group_id'],$vfl,$address);
00257       # send an email to notify the admins of the ite update
00258       list($additional_address, $sendall) = trackers_data_get_item_notification_info($item_id, ARTIFACT, 1);
00259       if ((trim($address) != "") && (trim($additional_address) != "")) 
00260         { $address .= ", "; }
00261       $address .= $additional_address;
00262       # exclude the submitter from the notification, he got a specific mail
00263       # for himself
00264       trackers_mail_followup($item_id, $address, false, user_getname());
00265 #      fb(sprintf(_("Task #%s opened"),$item_id));
00266     }
00267 
00268   if ($GLOBALS['sys_group_id'] != $group_id)
00269     {
00270       # get site-specific content, if it is not the localadmin project
00271       site_header(array('title'=>_("Registration Complete")));
00272       utils_get_content("register/confirmation");
00273       site_footer(array());
00274     }
00275   else
00276     {
00277       # redirect to the trigger page
00278       session_redirect($GLOBALS['sys_home']."admin/triggercreation.php?group_id=".$group_id);
00279     }
00280 
00281 }
00282 else if ($i_disagree && $group_id && $rand_hash)
00283 {
00284   $HTML->header(array('title'=>_("Registration Deleted")));
00285   $result=db_query("DELETE FROM groups "
00286                    .    "WHERE group_id='$group_id' AND rand_hash='__$rand_hash'");
00287 
00288   print '
00289 <h3>'._("Project Deleted").'</h3>
00290 <p>'._("Please try again any other time.").'</p>';
00291 
00292   $HTML->footer(array());
00293 
00294 }
00295 else
00296 {
00297   exit_error('Error',_("This is an invalid state.").' '
00298              ._("Some form variables were missing.").' '
00299              .sprintf(_("If you are certain you entered everything, %sPLEASE%s report to %s including info on your browser and platform configuration."),'<strong>','</strong>',$GLOBALS['sys_email_address']));
00300 }
00301 
00302 ?>

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