- informs interested people about application modification.

- tell what changed in the email
- get rid of addslashes and use compile_update_string
This commit is contained in:
Jonathan Ernst
2005-02-09 23:49:56 +00:00
committed by WineHQ
parent b9944c9ae7
commit df02378f26

View File

@@ -125,54 +125,71 @@ class Application {
/** /**
* Update application. * Update application.
* FIXME: Informs interested people about the modification.
* FIXME: tell what changed in the email.
* FIXME: get rid of addslashes and use compile_update_string
* Returns true on success and false on failure. * Returns true on success and false on failure.
*/ */
function update($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null) function update($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null)
{ {
if ($sName) $sWhatChanged = "";
if ($sName && $sName!=$this->sName)
{ {
if (!query_appdb("UPDATE appFamily SET appName = '".addslashes($sName)."' WHERE appId = ".$this->iAppId)) $sUpdate = compile_update_string(array('appName' => sName));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false; return false;
$sWhatChanged .= "Name was changed from ".$this->sName." to ".$sName.".\n\n";
$this->sName = $sName; $this->sName = $sName;
} }
if ($sDescription) if ($sDescription && $sDescription!=$this->sDescription)
{ {
if (!query_appdb("UPDATE appFamily SET description = '".addslashes($sDescription)."' WHERE appId = ".$this->iAppId)) $sUpdate = compile_update_string(array('description' => $sDescription));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false; return false;
$sWhatChanged .= "Description was changed from\n ".$this->sDescription."\n to \n".$sDescription.".\n\n";
$this->sDescription = $sDescription; $this->sDescription = $sDescription;
} }
if ($sKeywords) if ($sKeywords && $sKeywords!=$this->sKeywords)
{ {
if (!query_appdb("UPDATE appFamily SET keywords = '".addslashes($sKeywords)."' WHERE appId = ".$this->iAppId)) $sUpdate = compile_update_string(array('keywords' => $sKeywords));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false; return false;
$sWhatChanged .= "Keywords were changed from\n ".$this->sKeywords."\n to \n".$sKeywords.".\n\n";
$this->sKeywords = $sKeywords; $this->sKeywords = $sKeywords;
} }
if ($sWebpage) if ($sWebpage && $sWebpage!=$this->sWebpage)
{ {
if (!query_appdb("UPDATE appFamily SET webPage = '".addslashes($sWebpage)."' WHERE appId = ".$this->iAppId)) $sUpdate = compile_update_string(array('webPage' => $sWebpage));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false; return false;
$sWhatChanged .= "Web page was changed from ".$this->sWebpage." to ".$sWebpage.".\n\n";
$this->sWebpage = $sWebpage; $this->sWebpage = $sWebpage;
} }
if ($iVendorId) if ($iVendorId && $iVendorId!=$this->iVendorId)
{ {
if (!query_appdb("UPDATE appFamily SET vendorId = '".$iVendorId."' WHERE appId = ".$this->iAppId)) $sUpdate = compile_update_string(array('vendorId' => $iVendorId));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false; return false;
$oVendorBefore = new Vendor($this->iVendorId);
$oVendorAfter = new Vendor($iVendorId);
$sWhatChanged .= "Vendor was changed from ".$oVendorBefore->sName." to ".$oVendorBefore->sName.".\n\n";
$this->iVendorId = $iVendorId; $this->iVendorId = $iVendorId;
} }
if ($iCatId) if ($iCatId && $iCatId!=$this->iCatId)
{ {
if (!query_appdb("UPDATE appFamily SET catId = '".$iCatId."' WHERE appId = ".$this->iAppId)) $sUpdate = compile_update_string(array('catId' => $iCatId));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false; return false;
$oCatBefore = new Category($this->iCatId);
$oCatAfter = new Category($iCatId);
$sWhatChanged .= "Vendor was changed from ".$oCatBefore->sName." to ".$oCatAfter->sName.".\n\n";
$this->iCatId = $iCatId; $this->iCatId = $iCatId;
} }
if($sWhatChanged)
$this->mailSupermaintainers("edit",$sWhatChanged);
return true; return true;
} }
@@ -244,38 +261,43 @@ class Application {
} }
function mailSupermaintainers($bDeleted=false) function mailSupermaintainers($sAction="add",$sMsg=null)
{ {
if(!$bDeleted) switch($sAction)
{ {
if(!$this->bQueued) case "add":
{ if(!$this->bQueued)
$sSubject = "Application ".$this->sName." added by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."appview.php?appId=".$this->iAppId."\n";
if($this->iSubmitterId)
{ {
$oSubmitter = new User($this->iSubmitterId); $sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname;
$sMsg .= "This application has been submitted by ".$oSubmitter->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.
{
$sSubject = $this->sName." has been submitted by ".$_SESSION['current']->sRealname;
$sMsg .= "This application has been queued.";
$sMsg .= "\n"; $sMsg .= "\n";
addmsg("The application you submitted will be added to the database database after being reviewed.", "green");
} }
addmsg("The application was successfully added into the database.", "green"); break;
} else // Application queued. case "edit":
{ $sSubject = $this->sName." has been modified by ".$_SESSION['current']->sRealname;
$sSubject = "Application ".$this->sName." submitted by ".$_SESSION['current']->sRealname; addmsg("Application modified.", "green");
$sMsg .= "This application has been queued."; break;
$sMsg .= "\n"; case "delete":
addmsg("The application you submitted will be added to the database database after being reviewed.", "green"); $sSubject = $this->sName." has been deleted by ".$_SESSION['current']->sRealname;
} addmsg("Application deleted.", "green");
} else // Application deleted. break;
{
$sSubject = "Application ".$this->sName." deleted by ".$_SESSION['current']->sRealname;
addmsg("Application deleted.", "green");
} }
$sEmail = get_notify_email_address_list($this->iAppId); $sEmail = get_notify_email_address_list($this->iAppId);
if($sEmail) if($sEmail)
mail_appdb($sEmail, $sSubject ,$sMsg); mail_appdb($sEmail, $sSubject ,$sMsg);
} }
} }