Indefero

Indefero Commit Details


Date:2011-05-31 06:58:12 (13 years 6 months ago)
Author:William MARTIN
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:95cc7f627ffb6322a6d3592f1c57cf3815f0dd3a
Parents: b9407f6aee6eff9e9c8174b1ecab761c898ae949
Message:Process a md5 on the uploaded file, and display it in the per file view. - The uploader can check that the uploaded file is correct - The downloader can check his download too

Changes:

File differences

src/IDF/Migrations/17DownloadMD5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 CĂ©ondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Add the md5 column for the download model.
*/
function IDF_Migrations_12DownloadMD5_up($params=null)
{
$table = Pluf::factory('IDF_Upload')->getSqlTable();
$sql = array();
$sql['PostgreSQL'] = 'ALTER TABLE '.$table.' ADD COLUMN "md5" TEXT DEFAULT \'\'';
$sql['MySQL'] = 'ALTER TABLE '.$table.' ADD COLUMN `md5` LONGTEXT DEFAULT \'\'';
$db = Pluf::db();
$engine = Pluf::f('db_engine');
if (!isset($sql[$engine])) {
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
}
function IDF_Migrations_12DownloadDesc_down($params=null)
{
$table = Pluf::factory('IDF_Upload')->getSqlTable();
$sql = array();
$sql['PostgreSQL'] = 'ALTER TABLE '.$table.' DROP COLUMN "md5"';
$sql['MySQL'] = 'ALTER TABLE '.$table.' DROP COLUMN `md5`';
$db = Pluf::db();
$engine = Pluf::f('db_engine');
if (!isset($sql[$engine])) {
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
}
src/IDF/Upload.php
7777
7878
7979
80
81
82
83
84
85
8086
8187
8288
......
144150
145151
146152
153
147154
148155
149156
'default' => 0,
'verbose' => __('file size in bytes'),
),
'md5' =>
array(
'type' => 'Pluf_DB_Field_Text',
'blank' => true,
'verbose' => __('MD5'),
),
'submitter' =>
array(
'type' => 'Pluf_DB_Field_Foreignkey',
if ($this->id == '') {
$this->creation_dtime = gmdate('Y-m-d H:i:s');
$this->modif_dtime = gmdate('Y-m-d H:i:s');
$this->md5 = md5_file (Pluf::f('upload_path') . '/' . $this->get_project()->shortname . '/files/' . $this->file);
}
}
src/IDF/templates/idf/downloads/view.html
55
66
77
8
9
810
911
1012
<div class="download-file">
{if $deprecated}<p class="smaller">{blocktrans}<strong>Attention!</strong> This file is marked as deprecated, download it only if you are sure you need this specific version.{/blocktrans}</p>{/if}
<a href="{url 'IDF_Views_Download::download', array($project.shortname, $file.file)}">{$file}</a> - {$file.filesize|size}
<br />
<span class="helptext">{trans 'md5:'} {$file.md5}</span>
</div>
{if $file.changelog}
<h2 class="changes">{trans 'Changes'}</h2>

Archive Download the corresponding diff file

Page rendered in 0.08247s using 13 queries.