diff --git a/include/application.php b/include/application.php
index 9539b91..258df77 100644
--- a/include/application.php
+++ b/include/application.php
@@ -70,7 +70,9 @@ class Application {
$this->sName = $oRow->appName;
$this->sKeywords = $oRow->keywords;
$this->sDescription = $oRow->description;
- $this->sWebpage = $oRow->webPage;
+ //TODO: we should move the url to the appData table
+ // and return an id into the appData table here
+ $this->sWebpage = Url::normalize($oRow->webPage);
$this->sQueued = $oRow->queued;
}
diff --git a/include/url.php b/include/url.php
index e8ddb31..b3451f1 100644
--- a/include/url.php
+++ b/include/url.php
@@ -21,27 +21,32 @@ class Url {
/**
* Constructor, fetches the url $iUrlId is given.
*/
- function Url($iUrlId = null)
+ function Url($iUrlId = null, $oRow = null)
{
- // we are working on an existing url
- if($iUrlId)
+ if(!$iUrlId && !$oRow)
+ return;
+
+ if(!$oRow)
{
$sQuery = "SELECT appData.*
FROM appData
WHERE type = 'url'
AND id = '?'";
- if($hResult = query_parameters($sQuery, $iUrlId))
- {
- $oRow = mysql_fetch_object($hResult);
- $this->iUrlId = $iUrlId;
- $this->sDescription = $oRow->description;
- $this->iAppId = $oRow->appId;
- $this->iVersionId = $oRow->versionId;
- $this->sUrl = $oRow->url;
- $this->bQueued = $oRow->queued;
- $this->sSubmitTime = $oRow->submitTime;
- $this->iSubmitterId = $oRow->submitterId;
- }
+ $hResult = query_parameters($sQuery, $iUrlId);
+ $oRow = mysql_fetch_object($hResult);
+ }
+
+ // we are working on an existing url
+ if($oRow)
+ {
+ $this->iUrlId = $iUrlId;
+ $this->sDescription = $oRow->description;
+ $this->iAppId = $oRow->appId;
+ $this->iVersionId = $oRow->versionId;
+ $this->sUrl = Url::normalize($oRow->url);
+ $this->bQueued = $oRow->queued;
+ $this->sSubmitTime = $oRow->submitTime;
+ $this->iSubmitterId = $oRow->submitterId;
}
}
@@ -423,8 +428,7 @@ class Url {
if($aValues["iVersionId"])
$sEmail = User::get_notify_email_address_list($aValues['iVersionId']);
else
- $sEmail = User::get_notify_email_address_list($aValues['iAppId'])
-;
+ $sEmail = User::get_notify_email_address_list($aValues['iAppId']);
if($sWhatChanged && $sEmail)
{
$oApp = new Application($aValues["iAppId"]);
@@ -482,13 +486,33 @@ class Url {
for($i = 0; $oRow = mysql_fetch_object($hResult); $i++)
{
+ // create a url object
+ $oUrl = new Url(null, $oRow);
+
$sReturn .= html_tr(array(
"Link",
- "url\">$oRow->description"),
+ "sUrl\">$oUrl->sDescription"),
"color1");
}
return $sReturn;
}
+
+ // if a url lacks "://" assume the url is an http one
+ // and prepend "http://"
+ function normalize($sTheUrl)
+ {
+ // if we already have "://" in the url
+ // we can leave the url alone
+ if(strpos($sTheUrl, "://") === false)
+ {
+ // assume this is a website and prepend "http://"
+ return "http://".$sTheUrl;
+ } else
+ {
+ // leave the url alone
+ return $sTheUrl;
+ }
+ }
}
?>