require_once $gfcommon.'frs/FRSFile.class.php';
/**
- * Factory method which creates a FRSRelease from an release id
+ * Factory method which creates a FRSRelease from an release id
*
- * @param int The release id
- * @param array The result array, if it's passed in
- * @return object FRSRelease object
+ * @param int $release_id The release id
+ * @param array $data 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 = array()) {
global $FRSRELEASE_OBJ;
if (!isset($FRSRELEASE_OBJ['_'.$release_id.'_'])) {
if ($data) {
var $release_files;
/**
- * Constructor.
+ * Constructor.
*
- * @param object The FRSPackage object to which this release is associated.
- * @param int The release_id.
- * @param array The associative array of data.
- * @return boolean success.
+ * @param object $FRSPackage The FRSPackage object to which this release is associated.
+ * @param int|bool $release_id The release_id.
+ * @param array|bool $arr The associative array of data.
+ * @return bool success.
*/
function FRSRelease(&$FRSPackage, $release_id = false, $arr = false) {
$this->Error();
if (!$FRSPackage || !is_object($FRSPackage)) {
- $this->setError('FRSRelease:: No Valid FRSPackage Object');
+ $this->setError(_('Invalid FRS Package Object'));
return false;
}
if ($FRSPackage->isError()) {
- $this->setError('FRSRelease:: '.$FRSPackage->getErrorMessage());
+ $this->setError('FRSRelease: '.$FRSPackage->getErrorMessage());
return false;
}
$this->FRSPackage =& $FRSPackage;
}
/**
- * create - create a new release in the database.
+ * create - create a new release in the database.
*
- * @param string The name of the release.
- * @param string The release notes for the release.
- * @param string The change log for the release.
- * @param int Whether the notes/log are preformatted with \n chars (1) true (0) false.
- * @param int The unix date of the release.
- * @return boolean success.
+ * @param string $name The name of the release.
+ * @param string $notes The release notes for the release.
+ * @param string $changes The change log for the release.
+ * @param int $preformatted Whether the notes/log are preformatted with \n chars (1) true (0) false.
+ * @param int $release_date The unix date of the release.
+ * @return boolean success.
*/
function create($name,$notes,$changes,$preformatted,$release_date=false) {
if (strlen($name) < 3) {
}
$res = db_query_params ('SELECT * FROM frs_release WHERE package_id=$1 AND name=$2',
array ($this->FRSPackage->getID(),
- htmlspecialchars($name))) ;
+ htmlspecialchars($name))) ;
if (db_numrows($res)) {
$this->setError(_('Error Adding Release: Name Already Exists'));
return false;
user_getid(),
1)) ;
if (!$result) {
- $this->setError('Error Adding Release: '.db_error());
+ $this->setError(_('Error Adding Release: ').db_error());
db_rollback();
return false;
}
}
/**
- * fetchData - re-fetch the data for this Release from the database.
+ * fetchData - re-fetch the data for this Release from the database.
*
- * @param int The release_id.
- * @return boolean success.
+ * @param int $release_id The release_id.
+ * @return bool success.
*/
function fetchData($release_id) {
$res = db_query_params ('SELECT * FROM frs_release WHERE release_id=$1 AND package_id=$2',
array ($release_id,
- $this->FRSPackage->getID())) ;
+ $this->FRSPackage->getID())) ;
if (!$res || db_numrows($res) < 1) {
- $this->setError('FRSRelease::fetchData() Invalid release_id');
+ $this->setError(_('Invalid release_id'));
return false;
}
$this->data_array = db_fetch_array($res);
}
/**
- * getFRSPackage - get the FRSPackage object this release is associated with.
+ * getFRSPackage - get the FRSPackage object this release is associated with.
*
- * @return object The FRSPackage object.
+ * @return object The FRSPackage object.
*/
function &getFRSPackage() {
return $this->FRSPackage;
}
/**
- * getID - get this release_id.
+ * getID - get this release_id.
*
- * @return int The id of this release.
+ * @return int The id of this release.
*/
function getID() {
return $this->data_array['release_id'];
}
/**
- * getName - get the name of this release.
+ * getName - get the name of this release.
*
- * @return string The name of this release.
+ * @return string The name of this release.
*/
function getName() {
return $this->data_array['name'];
}
/**
- * getFileName - get the filename of this release.
+ * getFileName - get the filename of this release.
*
- * @return string The filename of this release.
+ * @return string The filename of this release.
*/
function getFileName() {
return util_secure_filename($this->data_array['name']);
}
/**
- * getStatus - get the status of this release.
+ * getStatus - get the status of this release.
*
- * @return int The status.
+ * @return int The status.
*/
function getStatus() {
return $this->data_array['status_id'];
}
/**
- * getNotes - get the release notes of this release.
+ * getNotes - get the release notes of this release.
*
- * @return string The release notes.
+ * @return string The release notes.
*/
function getNotes() {
return $this->data_array['notes'];
}
/**
- * getChanges - get the changelog of this release.
+ * getChanges - get the changelog of this release.
*
- * @return string The changelog.
+ * @return string The changelog.
*/
function getChanges() {
return $this->data_array['changes'];
}
/**
- * getPreformatted - get the preformatted option of this release.
+ * getPreformatted - get the preformatted option of this release.
*
- * @return boolean preserve_formatting.
+ * @return boolean preserve_formatting.
*/
function getPreformatted() {
return $this->data_array['preformatted'];
}
/**
- * getReleaseDate - get the releasedate of this release.
+ * getReleaseDate - get the releasedate of this release.
*
- * @return int The release date in unix time.
+ * @return int The release date in unix time.
*/
function getReleaseDate() {
return $this->data_array['release_date'];
}
/**
- * 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.
+ * @return boolean success.
*/
function sendNotice() {
$arr =& $this->FRSPackage->getMonitorIDs();
$date = date('Y-m-d H:i',time());
$subject = sprintf (_('[%1$s Release] %2$s'),
- $this->FRSPackage->Group->getUnixName(),
- $this->FRSPackage->getName());
- $text = stripcslashes(sprintf(_('Project %1$s (%2$s) has released a new version of package ā%3$sā.'),
+ $this->FRSPackage->Group->getUnixName(),
+ $this->FRSPackage->getName());
+ $text = sprintf(_('Project %1$s (%2$s) has released a new version of package ā%3$sā.'),
$this->FRSPackage->Group->getPublicName(),
$this->FRSPackage->Group->getUnixName(),
$this->FRSPackage->getName())
. 'notified in the future, please login to %s and click this link:'),
forge_get_config('forge_name'))
. "\n\n"
- . util_make_url ("/frs/monitor.php?filemodule_id=".$this->FRSPackage->getID()."&group_id=".$this->FRSPackage->Group->getID()."&stop=1"));
+ . 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);
}
/**
- * getFiles - gets all the file objects for files in this release.
+ * newFRSFile - generates a FRSFile (allows overloading by subclasses)
*
- * return array Array of FRSFile Objects.
+ * @param string FRS file identifier
+ * @param array fetched data from the DB
+ * @return FRSFile new FRSFile object.
+ */
+ protected function newFRSFile($file_id, $data) {
+ return new FRSFile($this,$file_id, $data);
+ }
+
+ /**
+ * getFiles - gets all the file objects for files in this release.
+ *
+ * @return array Array of FRSFile Objects.
*/
function &getFiles() {
if (!is_array($this->release_files) || count($this->release_files) < 1) {
$res = db_query_params ('SELECT * FROM frs_file_vw WHERE release_id=$1',
array ($this->getID())) ;
while ($arr = db_fetch_array($res)) {
- $this->release_files[]=new FRSFile($this,$arr['file_id'],$arr);
+ $this->release_files[]=$this->newFRSFile($arr['file_id'],$arr);
}
}
return $this->release_files;
}
/**
- * delete - delete this release and all its related data.
+ * delete - delete this release and all its related data.
*
- * @param bool I'm Sure.
- * @param bool I'm REALLY sure.
- * @return bool true/false;
+ * @param bool $sure I'm Sure.
+ * @param bool $really_sure I'm REALLY sure.
+ * @return bool true/false;
*/
function delete($sure, $really_sure) {
if (!$sure || !$really_sure) {
// 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');
+ $this->setError(_('Release delete error: trying to delete root dir'));
return false;
}
rmdir($dir);
}
/**
- * update - update a new release in the database.
+ * update - update a new release in the database.
*
- * @param int The status of this release from the frs_status table.
- * @param string The name of the release.
- * @param string The release notes for the release.
- * @param string The change log for the release.
- * @param int Whether the notes/log are preformatted with \n chars (1) true (0) false.
- * @param int The unix date of the release.
- * @return boolean success.
+ * @param int The status of this release from the frs_status table.
+ * @param string The name of the release.
+ * @param string The release notes for the release.
+ * @param string The change log for the release.
+ * @param int Whether the notes/log are preformatted with \n chars (1) true (0) false.
+ * @param int The unix date of the release.
+ * @return boolean success.
*/
function update($status, $name, $notes, $changes, $preformatted, $release_date) {
if (strlen($name) < 3) {
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))) ;
+ htmlspecialchars($name))) ;
if (db_numrows($res)) {
- $this->setError('FRSRelease::update() Error On Update: Name Already Exists');
+ $this->setError(_('Error On Update: Name Already Exists'));
return false;
}
}
changes=$4,preformatted=$5,release_date=$6,released_by=$7
WHERE package_id=$8 AND release_id=$9',
array (htmlspecialchars($name),
- $status,
- htmlspecialchars($notes),
- htmlspecialchars($changes),
- $preformatted,
- $release_date,
- user_getid(),
- $this->FRSPackage->getID(),
- $this->getID())) ;
+ $status,
+ htmlspecialchars($notes),
+ htmlspecialchars($changes),
+ $preformatted,
+ $release_date,
+ user_getid(),
+ $this->FRSPackage->getID(),
+ $this->getID())) ;
if (!$res || db_affected_rows($res) < 1) {
- $this->setError('FRSRelease::update() Error On Update: '.db_error());
+ $this->setError(sprintf(_('Error On Update: %s'), db_error()));
db_rollback();
return false;
}
$oldfilename = $this->getFileName();
if(!$this->fetchData($this->getID())){
- $this->setError("FRSRelease::update() Error Updating Release: Couldn't fetch data");
+ $this->setError(_("Error Updating Release: Couldn't fetch data"));
db_rollback();
return false;
}
if (($oldfilename!=$newfilename) && is_dir($olddirlocation)) {
if (is_dir($newdirlocation)) {
- $this->setError('FRSRelease::update() Error Updating Release: Directory Already Exists');
+ $this->setError(_('Error Updating Release: Directory Already Exists'));
db_rollback();
return false;
} else {
- if(!rename($olddirlocation,$newdirlocation)) {
- $this->setError("FRSRelease::update() Error Updating Release: Couldn't rename dir");
+ if(!rename($olddirlocation, $newdirlocation)) {
+ $this->setError(_("Error Updating Release: Couldn't rename dir"));
db_rollback();
return false;
}