00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: download.php 4969 2005-11-15 10:32:43Z yeupou $
00006 #
00007 # Copyright 2005 (c) Mathieu Roy <yeupou--gnu.org>
00008 #
00009 #
00010 # The Savane project is free software; you can redistribute it and/or
00011 # modify it under the terms of the GNU General Public License
00012 # as published by the Free Software Foundation; either version 2
00013 # of the License, or (at your option) any later version.
00014 #
00015 # The Savane project is distributed in the hope that it will be useful,
00016 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 # GNU General Public License for more details.
00019 #
00020 # You should have received a copy of the GNU General Public License
00021 # along with the Savane project; if not, write to the Free Software
00022 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00023
00024 register_globals_off();
00025
00026 # We need to do this step in a page separated from the export.php page because
00027 # ARTIFACT must be set to task
00028
00029 if (!$group_id)
00030 { exit_no_group(); }
00031
00032 $project=project_get_object($group_id);
00033
00034 if (!member_check(0, $group_id))
00035 {
00036 exit_error(_("Data Export is currently restricted to projects members"));
00037 }
00038
00039 $from = sane_get("from");
00040 $export_id = sane_get("export_id");
00041
00042 if (!$from || !$export_id)
00043 {
00044 exit_missing_param();
00045 }
00046
00047 $sql = "SELECT * FROM trackers_export WHERE export_id='$export_id' LIMIT 1";
00048 $result = db_query($sql);
00049 if (db_numrows($result) < 1)
00050 {
00051 # No such export id or not in 'I' status
00052 exit_error(_("This export job cannot be modified"));
00053 }
00054 $timestamp = db_result($result, 0, "date");
00055 $requested_hour = db_result($result, 0, "frequency_hour");
00056 $requested_day = db_result($result, 0, "frequency_day");
00057
00058 trackers_init($group_id);
00059 $vfl = array();
00060 # For now, hardcode the export directory to domain/export.
00061 # It is easy to set up a redirection from there to some other server
00062 # so we will avoid for now adding plenty of configuration options.
00063 # We put it in a directory for each group and user, so it is lighter for
00064 # the filesystem and it will allow us to implement .htaccess restrictions
00065 # on some directories
00066 $export_url = $GLOBALS['sys_https_url'].$GLOBALS['sys_home']."export/$group_name/".user_getname()."/".$export_id.".xml";
00067
00068 $vfl['summary'] = 'Data Export #'.$export_id.' ('.$from.')';
00069
00070 # FIXME: Job details is currently not shown in a user friendly way
00071 $vfl['details'] = 'A new export job has been registered.
00072
00073 This task has been created to keep the project informed. However, only '.user_getname(0, 1).', that created the job, can remove the job itself.
00074
00075 ######### JOB URL #########
00076
00077 Once the job will be done, it will be available at:
00078
00079 <'.$export_url.'>
00080
00081
00082 ######### JOB REMOVAL #########
00083
00084 Closing this task will not remove the job. To remove the job, '.user_getname(0, 1).' must go at
00085 <'.$GLOBALS['sys_https_url'].$GLOBALS['sys_home'].$from.'/export.php?group='.$group_name.'>
00086
00087
00088 ######### JOB DETAILS #########
00089
00090 The SQL query will be:
00091 '.db_result($result, 0, 'sql').'
00092
00093
00094 (Note: We are aware this information is not tremendously user-friendly. This will be improved in future Savane releases)
00095 ';
00096
00097 # Set the task to be private per default, until we implement access
00098 # restriction, that is the way to go.
00099 # Apache should be configured not to allow people to browse export/
00100 $vfl['privacy'] = '2';
00101 $vfl['planned_starting_date'] = date("Y")."-".date("m")."-".date("d");
00102 # As we cannot store a specific hour, we must add 24h to the close
00103 # date
00104 $vfl['planned_close_date'] = strftime("%Y-%m", $timestamp)."-".(strftime("%d", $timestamp)+1);
00105 if ($requested_hour && $requested_day)
00106 {
00107 # If it is frequent job, artificially increment the year because
00108 # the ending date is not the date of the next export
00109 $vfl['planned_close_date'] = (date("Y")+2)."-".strftime("%m-%d", $timestamp);
00110 }
00111
00112 $address = "";
00113 $item_id = trackers_data_create_item($group_id,$vfl,$address);
00114
00115 # Send email notification
00116 list($additional_address, $sendall) = trackers_data_get_item_notification_info($item_id, 'task', 1);
00117 if ((trim($address) != "") && (trim($additional_address) != ""))
00118 { $address .= ", "; }
00119 $address .= $additional_address;
00120 trackers_mail_followup($item_id, $address, false);
00121
00122 # Update the export table to make it aware of the relevant task
00123 $sql = "UPDATE trackers_export SET status='P', task_id='$item_id' WHERE export_id='$export_id' LIMIT 1";
00124 $result = db_query($sql);
00125
00126 session_redirect($GLOBALS['sys_home'].$from."/export.php?group=".rawurlencode($group_name)."&feedback=".rawurlencode(sprintf(_("Export job #%s registered, task #%s created"), $export_id, $item_id)));
00127
00128 ?>