* Copyright 2002, Tim Perdue/GForge, LLC
* Copyright 2009, Roland Mas
*
- * This file is part of FusionForge.
+ * This file is part of FusionForge. FusionForge 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 Licence, or (at your option)
+ * any later version.
*
- * FusionForge 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.
- *
- * FusionForge 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.
+ * FusionForge 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 FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once $gfcommon.'include/Error.class.php';
* @param array The result array, if it's passed in
* @return object FRSRelease object
*/
-function &frsrelease_get_object($release_id, $data=false) {
+function frsrelease_get_object($release_id, $data = false) {
global $FRSRELEASE_OBJ;
if (!isset($FRSRELEASE_OBJ['_'.$release_id.'_'])) {
if ($data) {
- //the db result handle was passed in
+ //the db result handle was passed in
} else {
$res = db_query_params ('SELECT * FROM frs_release WHERE release_id=$1',
array ($release_id)) ;
}
$data = db_fetch_array($res);
}
- $FRSPackage =& frspackage_get_object($data['package_id']);
+ $FRSPackage = frspackage_get_object($data['package_id']);
$FRSRELEASE_OBJ['_'.$release_id.'_']= new FRSRelease($FRSPackage,$data['release_id'],$data);
}
return $FRSRELEASE_OBJ['_'.$release_id.'_'];
* @param array The associative array of data.
* @return boolean success.
*/
- function FRSRelease(&$FRSPackage, $release_id=false, $arr=false) {
+ function FRSRelease(&$FRSPackage, $release_id = false, $arr = false) {
$this->Error();
if (!$FRSPackage || !is_object($FRSPackage)) {
$this->setError('FRSRelease:: No Valid FRSPackage Object');
* @return string The filename of this release.
*/
function getFileName() {
- return preg_replace("/[^-A-Z0-9_\.]/i",'',$this->data_array['name']);
+ return util_secure_filename($this->data_array['name']);
}
/**
}
/**
- * sendNotice - the logic to send an email/jabber notice for a release.
+ * sendNotice - the logic to send an email notice for a release.
*
* @return boolean success.
*/
$this->FRSPackage->getName());
$text = stripcslashes(sprintf(_('Project %1$s (%2$s) has released a new version of package "%3$s".
-Release note:
-
+Release note:
+
%4$s
-
+
Change note:
%5$s
notified in the future, please login to %7$s and click this link:
%8$s
-
-
-
+
+
+
'
),
$this->FRSPackage->Group->getPublicName(),
$this->FRSPackage->Group->getUnixName(),
- $this->FRSPackage->getName(),
+ $this->FRSPackage->getName(),
$this->getNotes(),
$this->getChanges(),
util_make_url ("/frs/?group_id=". $this->FRSPackage->Group->getID() ."&release_id=". $this->getID()),
- forge_get_config ('forge_name'),
+ forge_get_config('forge_name'),
util_make_url ("/frs/monitor.php?filemodule_id=".$this->FRSPackage->getID()."&group_id=".$this->FRSPackage->Group->getID()."&stop=1")));
// $text = util_line_wrap($text);
if (count($arr)) {
util_handle_message(array_unique($arr),$subject,$text);
}
-
+
}
/**
*/
function delete($sure, $really_sure) {
if (!$sure || !$really_sure) {
- $this->setMissingParamsError();
+ $this->setMissingParamsError(_('Please tick all checkboxes.'));
return false;
}
if (!forge_check_perm ('frs', $this->FRSPackage->Group->getID(), 'write')) {
$this->FRSPackage->Group->getUnixName() . '/' .
$this->FRSPackage->getFileName().'/'.
$this->getFileName().'/';
-
+
// double-check we're not trying to remove root dir
if (util_is_root_dir($dir)) {
$this->setError('Release::delete error: trying to delete root dir');
return false;
}
- exec('rm -rf '.$dir);
-
+ rmdir($dir);
+
db_query_params ('DELETE FROM frs_release WHERE release_id=$1 AND package_id=$2',
array ($this->getID(),
$this->FRSPackage->getID())) ;
* @param int The unix date of the release.
* @return boolean success.
*/
- function update($status,$name,$notes,$changes,$preformatted,$release_date) {
+ function update($status, $name, $notes, $changes, $preformatted, $release_date) {
if (strlen($name) < 3) {
$this->setError(_('FRSPackage Name Must Be At Least 3 Characters'));
return false;
}
-
- if (!forge_check_perm ('frs', $this->FRSPackage->Group->getID(), 'write')) {
+
+ if (!forge_check_perm('frs', $this->FRSPackage->Group->getID(), 'write')) {
$this->setPermissionDeniedError();
return false;
}
} else {
$preformatted = 0;
}
-
- if($this->getName()!=htmlspecialchars($name)) {
+
+ if($this->getName() != htmlspecialchars($name)) {
$res = db_query_params ('SELECT * FROM frs_release WHERE package_id=$1 AND name=$2',
array ($this->FRSPackage->getID(),
htmlspecialchars($name))) ;
$this->setError('FRSRelease::update() Error On Update: Name Already Exists');
return false;
}
- }
+ }
db_begin();
$res = db_query_params ('UPDATE frs_release SET name=$1,status_id=$2,notes=$3,
changes=$4,preformatted=$5,release_date=$6,released_by=$7
$newfilename = $this->getFileName();
$olddirlocation = forge_get_config('upload_dir').'/'.$this->FRSPackage->Group->getUnixName().'/'.$this->FRSPackage->getFileName().'/'.$oldfilename;
$newdirlocation = forge_get_config('upload_dir').'/'.$this->FRSPackage->Group->getUnixName().'/'.$this->FRSPackage->getFileName().'/'.$newfilename;
-
+
if (($oldfilename!=$newfilename) && is_dir($olddirlocation)) {
if (is_dir($newdirlocation)) {
$this->setError('FRSRelease::update() Error Updating Release: Directory Already Exists');
db_rollback();
- return false;
+ return false;
} else {
if(!rename($olddirlocation,$newdirlocation)) {
$this->setError("FRSRelease::update() Error Updating Release: Couldn't rename dir");
return false;
}
}
- }
+ }
db_commit();
+ $this->FRSPackage->createNewestReleaseFilesAsZip();
return true;
}