3 * FusionForge file release system
5 * Copyright 2007 SoftwareEntwicklung Beratung Schulung
6 * Copyright 2007 Karl Heinz Marbaise
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfcommon.'include/FFError.class.php';
26 function get_frs_filetypes() {
27 $res=db_query_params('SELECT * FROM frs_filetype', array());
28 if (db_numrows($res) < 1) {
32 while($arr = db_fetch_array($res)) {
33 $ps[]=new FRSFileType($arr['type_id'],$arr['name']);
38 class FRSFileType extends FFError {
41 * Associative array of data from db.
43 * @var array $data_array.
47 function __construct($type_id=false, $name=false) {
48 parent::__construct();
49 if($type_id && $name) {
50 $this->data_array = array( 'type_id' => $type_id, 'name' => $name);
52 $this->fetchData($type_id);
57 * fetchData - re-fetch the data for this FRSFileType from the database.
59 * @param int $type_id The type_id
60 * @return bool success.
62 function fetchData($type_id) {
63 $res=db_query_params('SELECT * FROM frs_filetype WHERE type_id=$1', array($type_id));
64 if (!$res || db_numrows($res) < 1) {
65 $this->setError(_('Invalid type_id'));
68 $this->data_array = db_fetch_array($res);
74 * getID - get this file_id.
76 * @return int The id of this file.
79 return $this->data_array['type_id'];
83 * getName - get the name of this file.
85 * @return string The name of this file.
88 return $this->data_array['name'];