- 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:
@@ -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,13 +261,14 @@ class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function mailSupermaintainers($bDeleted=false)
|
function mailSupermaintainers($sAction="add",$sMsg=null)
|
||||||
{
|
{
|
||||||
if(!$bDeleted)
|
switch($sAction)
|
||||||
{
|
{
|
||||||
|
case "add":
|
||||||
if(!$this->bQueued)
|
if(!$this->bQueued)
|
||||||
{
|
{
|
||||||
$sSubject = "Application ".$this->sName." added by ".$_SESSION['current']->sRealname;
|
$sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname;
|
||||||
$sMsg = APPDB_ROOT."appview.php?appId=".$this->iAppId."\n";
|
$sMsg = APPDB_ROOT."appview.php?appId=".$this->iAppId."\n";
|
||||||
if($this->iSubmitterId)
|
if($this->iSubmitterId)
|
||||||
{
|
{
|
||||||
@@ -261,21 +279,25 @@ class Application {
|
|||||||
addmsg("The application was successfully added into the database.", "green");
|
addmsg("The application was successfully added into the database.", "green");
|
||||||
} else // Application queued.
|
} else // Application queued.
|
||||||
{
|
{
|
||||||
$sSubject = "Application ".$this->sName." submitted by ".$_SESSION['current']->sRealname;
|
$sSubject = $this->sName." has been submitted by ".$_SESSION['current']->sRealname;
|
||||||
$sMsg .= "This application has been queued.";
|
$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 you submitted will be added to the database database after being reviewed.", "green");
|
||||||
}
|
}
|
||||||
} else // Application deleted.
|
break;
|
||||||
{
|
case "edit":
|
||||||
$sSubject = "Application ".$this->sName." deleted by ".$_SESSION['current']->sRealname;
|
$sSubject = $this->sName." has been modified by ".$_SESSION['current']->sRealname;
|
||||||
|
addmsg("Application modified.", "green");
|
||||||
|
break;
|
||||||
|
case "delete":
|
||||||
|
$sSubject = $this->sName." has been deleted by ".$_SESSION['current']->sRealname;
|
||||||
addmsg("Application deleted.", "green");
|
addmsg("Application deleted.", "green");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user