2004-12-12 03:51:51 +00:00
|
|
|
<?php
|
|
|
|
|
/***********************************************************/
|
2004-03-15 16:22:00 +00:00
|
|
|
/* this class represents an application incl. all versions */
|
2004-12-12 03:51:51 +00:00
|
|
|
/***********************************************************/
|
|
|
|
|
|
2005-02-07 23:21:33 +00:00
|
|
|
require_once(BASE."include/version.php");
|
|
|
|
|
require_once(BASE."include/vendor.php");
|
2005-02-11 01:34:16 +00:00
|
|
|
require_once(BASE."include/url.php");
|
2005-02-06 17:49:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Application class for handling applications.
|
|
|
|
|
*/
|
2004-03-15 16:22:00 +00:00
|
|
|
class Application {
|
|
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
var $iAppId;
|
|
|
|
|
var $iVendorId;
|
|
|
|
|
var $iCatId;
|
|
|
|
|
var $sName;
|
|
|
|
|
var $sKeywords;
|
|
|
|
|
var $sDescription;
|
|
|
|
|
var $sWebpage;
|
|
|
|
|
var $bQueued;
|
2005-02-07 23:21:33 +00:00
|
|
|
var $sSubmitTime;
|
2005-02-06 17:49:48 +00:00
|
|
|
var $iSubmitterId;
|
|
|
|
|
var $aVersionsIds; // an array that contains the versionId of every version linked to this app.
|
2005-02-11 01:34:16 +00:00
|
|
|
var $aUrlsIds; // an array that contains the screenshotId of every url linked to this version
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
/**
|
|
|
|
|
* constructor, fetches the data.
|
|
|
|
|
*/
|
|
|
|
|
function Application($iAppId = null)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-02-06 17:49:48 +00:00
|
|
|
// we are working on an existing application
|
2005-03-23 23:56:38 +00:00
|
|
|
if(is_numeric($iAppId))
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* We fetch application data and versionsIds.
|
|
|
|
|
*/
|
|
|
|
|
$sQuery = "SELECT appFamily.*, appVersion.versionId AS versionId
|
|
|
|
|
FROM appFamily, appVersion
|
|
|
|
|
WHERE appFamily.appId = appVersion.appId
|
2005-02-19 01:21:14 +00:00
|
|
|
AND appVersion.queued='false'
|
2005-02-11 01:34:16 +00:00
|
|
|
AND appFamily.appId = ".$iAppId." ORDER BY versionName";
|
2005-02-06 17:49:48 +00:00
|
|
|
if($hResult = query_appdb($sQuery))
|
|
|
|
|
{
|
2005-02-09 23:53:25 +00:00
|
|
|
$this->aVersionsIds = array();
|
2005-02-06 17:49:48 +00:00
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
if(!$this->iAppId)
|
|
|
|
|
{
|
|
|
|
|
$this->iAppId = $iAppId;
|
|
|
|
|
$this->iVendorId = $oRow->vendorId;
|
|
|
|
|
$this->iCatId = $oRow->catId;
|
|
|
|
|
$this->iSubmitterId = $oRow->submitterId;
|
2005-02-07 23:21:33 +00:00
|
|
|
$this->sSubmitTime = $oRow->submitTime;
|
2005-02-06 17:49:48 +00:00
|
|
|
$this->sDate = $oRow->submitTime;
|
|
|
|
|
$this->sName = $oRow->appName;
|
|
|
|
|
$this->sKeywords = $oRow->keywords;
|
|
|
|
|
$this->sDescription = $oRow->description;
|
|
|
|
|
$this->sWebpage = $oRow->webPage;
|
2005-02-24 04:49:27 +00:00
|
|
|
$this->bQueued = ($oRow->queued=="true")?true:false;
|
2005-02-06 17:49:48 +00:00
|
|
|
}
|
|
|
|
|
$this->aVersionsIds[] = $oRow->versionId;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
/*
|
|
|
|
|
* Then we fetch the data related to this application if the first query didn't return anything.
|
|
|
|
|
* This can happen if an application has no version linked to it.
|
|
|
|
|
*/
|
|
|
|
|
if(!$this->appId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT *
|
|
|
|
|
FROM appFamily
|
|
|
|
|
WHERE appId = ".$iAppId;
|
|
|
|
|
if($hResult = query_appdb($sQuery))
|
|
|
|
|
{
|
|
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
$this->iAppId = $iAppId;
|
|
|
|
|
$this->iVendorId = $oRow->vendorId;
|
|
|
|
|
$this->iCatId = $oRow->catId;
|
|
|
|
|
$this->iSubmitterId = $oRow->submitterId;
|
2005-02-20 01:55:53 +00:00
|
|
|
$this->sSubmitTime = $oRow->submitTime;
|
2005-02-06 17:49:48 +00:00
|
|
|
$this->sDate = $oRow->submitTime;
|
|
|
|
|
$this->sName = $oRow->appName;
|
|
|
|
|
$this->sKeywords = $oRow->keywords;
|
|
|
|
|
$this->sDescription = $oRow->description;
|
|
|
|
|
$this->sWebpage = $oRow->webPage;
|
2005-02-24 04:49:27 +00:00
|
|
|
$this->bQueued = ($oRow->queued=="true")?true:false;
|
2005-02-06 17:49:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-02-11 01:34:16 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* We fetch urlsIds.
|
|
|
|
|
*/
|
|
|
|
|
$this->aUrlsIds = array();
|
|
|
|
|
$sQuery = "SELECT id
|
|
|
|
|
FROM appData
|
|
|
|
|
WHERE type = 'url'
|
|
|
|
|
AND appId = ".$iAppId;
|
|
|
|
|
|
|
|
|
|
if($hResult = query_appdb($sQuery))
|
|
|
|
|
{
|
|
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
$this->aUrlsIds[] = $oRow->id;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-06 17:49:48 +00:00
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
/**
|
|
|
|
|
* Creates a new application.
|
|
|
|
|
*/
|
|
|
|
|
function create($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-02-06 17:49:48 +00:00
|
|
|
// Security, if we are not an administrator the application must be queued.
|
|
|
|
|
if(!($_SESSION['current']->hasPriv("admin")))
|
|
|
|
|
$this->bQueued = true;
|
|
|
|
|
else
|
|
|
|
|
$this->bQueued = false;
|
|
|
|
|
|
|
|
|
|
$aInsert = compile_insert_string(array( 'appName' => $sName,
|
|
|
|
|
'description'=> $sDescription,
|
|
|
|
|
'keywords' => $sKeywords,
|
|
|
|
|
'webPage' => $sWebpage,
|
|
|
|
|
'vendorId' => $iVendorId,
|
|
|
|
|
'catId' => $iCatId,
|
2005-02-17 01:18:13 +00:00
|
|
|
'submitterId'=> $_SESSION['current']->iUserId,
|
2005-02-21 01:37:06 +00:00
|
|
|
'queued' => $this->bQueued?"true":"false" ));
|
2005-02-06 17:49:48 +00:00
|
|
|
$sFields = "({$aInsert['FIELDS']})";
|
|
|
|
|
$sValues = "({$aInsert['VALUES']})";
|
|
|
|
|
|
|
|
|
|
if(query_appdb("INSERT INTO appFamily $sFields VALUES $sValues", "Error while creating a new application."))
|
|
|
|
|
{
|
|
|
|
|
$this->iAppId = mysql_insert_id();
|
|
|
|
|
$this->application($this->iAppId);
|
2005-02-11 01:36:24 +00:00
|
|
|
$this->mailSupermaintainers(); // Only administrators will be mailed as no supermaintainers exist for this app.
|
2005-02-06 17:49:48 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update application.
|
|
|
|
|
* Returns true on success and false on failure.
|
|
|
|
|
*/
|
|
|
|
|
function update($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
$sWhatChanged = "";
|
|
|
|
|
|
|
|
|
|
if ($sName && $sName!=$this->sName)
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-20 01:56:53 +00:00
|
|
|
$sUpdate = compile_update_string(array('appName' => $sName));
|
2005-02-09 23:49:56 +00:00
|
|
|
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
2005-02-06 17:49:48 +00:00
|
|
|
return false;
|
2005-02-09 23:49:56 +00:00
|
|
|
$sWhatChanged .= "Name was changed from ".$this->sName." to ".$sName.".\n\n";
|
2005-02-06 17:49:48 +00:00
|
|
|
$this->sName = $sName;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-09 23:49:56 +00:00
|
|
|
if ($sDescription && $sDescription!=$this->sDescription)
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
$sUpdate = compile_update_string(array('description' => $sDescription));
|
|
|
|
|
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
2005-02-06 17:49:48 +00:00
|
|
|
return false;
|
2005-02-09 23:49:56 +00:00
|
|
|
$sWhatChanged .= "Description was changed from\n ".$this->sDescription."\n to \n".$sDescription.".\n\n";
|
2005-02-06 17:49:48 +00:00
|
|
|
$this->sDescription = $sDescription;
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-02-09 23:49:56 +00:00
|
|
|
if ($sKeywords && $sKeywords!=$this->sKeywords)
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
$sUpdate = compile_update_string(array('keywords' => $sKeywords));
|
|
|
|
|
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
2005-02-06 17:49:48 +00:00
|
|
|
return false;
|
2005-02-09 23:49:56 +00:00
|
|
|
$sWhatChanged .= "Keywords were changed from\n ".$this->sKeywords."\n to \n".$sKeywords.".\n\n";
|
2005-02-06 17:49:48 +00:00
|
|
|
$this->sKeywords = $sKeywords;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-09 23:49:56 +00:00
|
|
|
if ($sWebpage && $sWebpage!=$this->sWebpage)
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
$sUpdate = compile_update_string(array('webPage' => $sWebpage));
|
|
|
|
|
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
2005-02-06 17:49:48 +00:00
|
|
|
return false;
|
2005-02-09 23:49:56 +00:00
|
|
|
$sWhatChanged .= "Web page was changed from ".$this->sWebpage." to ".$sWebpage.".\n\n";
|
2005-02-06 17:49:48 +00:00
|
|
|
$this->sWebpage = $sWebpage;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-09 23:49:56 +00:00
|
|
|
if ($iVendorId && $iVendorId!=$this->iVendorId)
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
$sUpdate = compile_update_string(array('vendorId' => $iVendorId));
|
|
|
|
|
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
2005-02-06 17:49:48 +00:00
|
|
|
return false;
|
2005-02-09 23:49:56 +00:00
|
|
|
$oVendorBefore = new Vendor($this->iVendorId);
|
|
|
|
|
$oVendorAfter = new Vendor($iVendorId);
|
|
|
|
|
$sWhatChanged .= "Vendor was changed from ".$oVendorBefore->sName." to ".$oVendorBefore->sName.".\n\n";
|
2005-02-06 17:49:48 +00:00
|
|
|
$this->iVendorId = $iVendorId;
|
|
|
|
|
}
|
2005-02-07 23:21:33 +00:00
|
|
|
|
2005-02-09 23:49:56 +00:00
|
|
|
if ($iCatId && $iCatId!=$this->iCatId)
|
2005-02-07 23:21:33 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
$sUpdate = compile_update_string(array('catId' => $iCatId));
|
|
|
|
|
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
2005-02-07 23:21:33 +00:00
|
|
|
return false;
|
2005-02-09 23:49:56 +00:00
|
|
|
$oCatBefore = new Category($this->iCatId);
|
|
|
|
|
$oCatAfter = new Category($iCatId);
|
|
|
|
|
$sWhatChanged .= "Vendor was changed from ".$oCatBefore->sName." to ".$oCatAfter->sName.".\n\n";
|
2005-02-07 23:21:33 +00:00
|
|
|
$this->iCatId = $iCatId;
|
|
|
|
|
}
|
2005-02-09 23:49:56 +00:00
|
|
|
if($sWhatChanged)
|
|
|
|
|
$this->mailSupermaintainers("edit",$sWhatChanged);
|
2005-02-06 17:49:48 +00:00
|
|
|
return true;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes the application from the database.
|
|
|
|
|
* and request the deletion of linked elements.
|
|
|
|
|
*/
|
|
|
|
|
function delete($bSilent=false)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-08-05 22:07:41 +00:00
|
|
|
/* don't let non-admins delete applications */
|
|
|
|
|
if(!($_SESSION['current']->hasPriv("admin")))
|
|
|
|
|
return;
|
|
|
|
|
|
2005-06-30 01:59:32 +00:00
|
|
|
foreach($this->aVersionsIds as $iVersionId)
|
|
|
|
|
{
|
|
|
|
|
$oVersion = new Version($iVersionId);
|
|
|
|
|
$oVersion->delete($bSilent);
|
|
|
|
|
}
|
|
|
|
|
foreach($this->aUrlsIds as $iUrlId)
|
|
|
|
|
{
|
|
|
|
|
$oUrl = new Url($iUrlId);
|
|
|
|
|
$oUrl->delete($bSilent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// remove any supermaintainers for this application so we don't orphan them
|
|
|
|
|
$sQuery = "DELETE from appMaintainers WHERE appId='".$this->iAppId."';";
|
|
|
|
|
if(!($hResult = query_appdb($sQuery)))
|
|
|
|
|
{
|
|
|
|
|
addmsg("Error removing app maintainers for the deleted application!", "red");
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
$sQuery = "DELETE FROM appFamily
|
|
|
|
|
WHERE appId = ".$this->iAppId."
|
|
|
|
|
LIMIT 1";
|
2005-06-30 01:59:32 +00:00
|
|
|
if(!($hResult = query_appdb($sQuery)))
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-06-30 01:59:32 +00:00
|
|
|
addmsg("Error deleting application!", "red");
|
2005-02-06 17:49:48 +00:00
|
|
|
}
|
2005-06-30 01:59:32 +00:00
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
if(!$bSilent)
|
2005-02-27 16:45:49 +00:00
|
|
|
$this->mailSupermaintainers("delete");
|
2005-02-06 17:49:48 +00:00
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Move application out of the queue.
|
|
|
|
|
*/
|
|
|
|
|
function unQueue()
|
|
|
|
|
{
|
|
|
|
|
// If we are not in the queue, we can't move the application out of the queue.
|
|
|
|
|
if(!$this->bQueued)
|
|
|
|
|
return false;
|
|
|
|
|
|
2005-02-07 23:21:33 +00:00
|
|
|
$sUpdate = compile_update_string(array('queued' => "false",
|
|
|
|
|
'keywords'=> str_replace(" *** ","",$this->sKeywords) ));
|
|
|
|
|
if(query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-27 16:45:49 +00:00
|
|
|
$this->bQueued = false;
|
2005-02-06 17:49:48 +00:00
|
|
|
// we send an e-mail to intersted people
|
|
|
|
|
$this->mailSubmitter();
|
|
|
|
|
$this->mailSupermaintainers();
|
|
|
|
|
|
|
|
|
|
// the application has been unqueued
|
|
|
|
|
addmsg("The application has been unqueued.", "green");
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
|
|
|
|
|
function mailSubmitter($bRejected=false)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-02-06 17:49:48 +00:00
|
|
|
if($this->iSubmitterId)
|
|
|
|
|
{
|
|
|
|
|
$oSubmitter = new User($this->iSubmitterId);
|
|
|
|
|
if(!$bRejected)
|
|
|
|
|
{
|
|
|
|
|
$sSubject = "Submitted application accepted";
|
|
|
|
|
$sMsg = "The application you submitted (".$this->sName.") has been accepted.";
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$sSubject = "Submitted application rejected";
|
|
|
|
|
$sMsg = "The application you submitted (".$this->sName.") has been rejected.";
|
|
|
|
|
}
|
|
|
|
|
$sMsg .= $_REQUEST['replyText']."\n";
|
|
|
|
|
$sMsg .= "We appreciate your help in making the Application Database better for all users.";
|
|
|
|
|
|
|
|
|
|
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
2004-11-09 22:42:12 +00:00
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
|
2005-02-09 23:49:56 +00:00
|
|
|
function mailSupermaintainers($sAction="add",$sMsg=null)
|
2004-12-25 20:03:34 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
switch($sAction)
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
case "add":
|
|
|
|
|
if(!$this->bQueued)
|
|
|
|
|
{
|
|
|
|
|
$sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname;
|
|
|
|
|
$sMsg = APPDB_ROOT."appview.php?appId=".$this->iAppId."\n";
|
|
|
|
|
if($this->iSubmitterId)
|
|
|
|
|
{
|
|
|
|
|
$oSubmitter = new User($this->iSubmitterId);
|
|
|
|
|
$sMsg .= "This application has been submitted by ".$oSubmitter->sRealname.".";
|
|
|
|
|
$sMsg .= "\n";
|
|
|
|
|
}
|
|
|
|
|
addmsg("The application was successfully added into the database.", "green");
|
|
|
|
|
} else // Application queued.
|
2005-02-06 17:49:48 +00:00
|
|
|
{
|
2005-02-09 23:49:56 +00:00
|
|
|
$sSubject = $this->sName." has been submitted by ".$_SESSION['current']->sRealname;
|
|
|
|
|
$sMsg .= "This application has been queued.";
|
2005-02-06 17:49:48 +00:00
|
|
|
$sMsg .= "\n";
|
2005-02-09 23:49:56 +00:00
|
|
|
addmsg("The application you submitted will be added to the database database after being reviewed.", "green");
|
2005-02-06 17:49:48 +00:00
|
|
|
}
|
2005-02-09 23:49:56 +00:00
|
|
|
break;
|
|
|
|
|
case "edit":
|
|
|
|
|
$sSubject = $this->sName." has been modified by ".$_SESSION['current']->sRealname;
|
2005-07-13 03:44:38 +00:00
|
|
|
$sMsg = APPDB_ROOT."appview.php?appId=".$this->iAppId."\n";
|
2005-02-09 23:49:56 +00:00
|
|
|
addmsg("Application modified.", "green");
|
|
|
|
|
break;
|
|
|
|
|
case "delete":
|
|
|
|
|
$sSubject = $this->sName." has been deleted by ".$_SESSION['current']->sRealname;
|
2005-05-09 22:12:19 +00:00
|
|
|
|
2005-05-09 22:34:47 +00:00
|
|
|
/* if replyText is set we should report the reason the application was deleted */
|
2005-05-09 22:12:19 +00:00
|
|
|
if($_REQUEST['replyText'])
|
|
|
|
|
{
|
|
|
|
|
$sMsg .= "Reason given:\n";
|
|
|
|
|
$sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-09 23:49:56 +00:00
|
|
|
addmsg("Application deleted.", "green");
|
|
|
|
|
break;
|
2005-02-06 17:49:48 +00:00
|
|
|
}
|
2005-02-07 23:21:33 +00:00
|
|
|
$sEmail = get_notify_email_address_list($this->iAppId);
|
2005-02-06 17:49:48 +00:00
|
|
|
if($sEmail)
|
|
|
|
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
|
|
|
|
}
|
2004-12-25 20:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-06 17:49:48 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Application functions that are not part of the class
|
|
|
|
|
*/
|
|
|
|
|
|
2005-02-04 02:59:05 +00:00
|
|
|
function lookup_version_name($versionId)
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
2005-02-04 02:59:05 +00:00
|
|
|
if(!$versionId) return null;
|
2005-02-02 02:39:40 +00:00
|
|
|
$result = query_appdb("SELECT versionName FROM appVersion WHERE versionId = $versionId");
|
2004-11-09 22:42:12 +00:00
|
|
|
if(!$result || mysql_num_rows($result) != 1)
|
|
|
|
|
return null;
|
|
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
return $ob->versionName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-04 02:59:05 +00:00
|
|
|
function lookup_app_name($appId)
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
2005-02-04 02:59:05 +00:00
|
|
|
if(!$appId) return null;
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT appName FROM appFamily WHERE appId = $appId");
|
2004-11-09 22:42:12 +00:00
|
|
|
if(!$result || mysql_num_rows($result) != 1)
|
|
|
|
|
return null;
|
|
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
return $ob->appName;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-02 02:38:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove html formatting from description and extract the first part of the description only.
|
|
|
|
|
* This is to be used for search results, application summary tables, etc.
|
|
|
|
|
*/
|
|
|
|
|
function trim_description($sDescription)
|
|
|
|
|
{
|
|
|
|
|
// 1) let's take the first line of the description:
|
|
|
|
|
$aDesc = explode("\n",trim($sDescription),2);
|
|
|
|
|
// 2) maybe it's an html description and lines are separated with <br> or </p><p>
|
|
|
|
|
$aDesc = explode("<br>",$aDesc[0],2);
|
|
|
|
|
$aDesc = explode("<br />",$aDesc[0],2);
|
|
|
|
|
$aDesc = explode("</p><p>",$aDesc[0],2);
|
|
|
|
|
$aDesc = explode("</p><p /><p>",$aDesc[0],2);
|
|
|
|
|
return trim(strip_tags($aDesc[0]));
|
|
|
|
|
}
|
2004-11-09 22:42:12 +00:00
|
|
|
?>
|