The change to the Repository source would be very minor ...
Assuming you have DNN 3.X and the Repository module installed, unzip the source code into the /DesktopModules/Repository folder and load up the DotNetNuke.Repository.sln solution file in Visual Studio 2003.
edit Repository.ascx.vb and look for the following code...
Case "Download"
IncrementDownloads(e.CommandArgument)
Dim target As String = oRepositoryBusinessController.GetSkinAttribute(xmlDoc, "DOWNLOAD", "Target", "NEW")
oRepositoryBusinessController.DownloadFile(e.CommandArgument, target) |
this code handles the download event, increments the download count, then calls the business controller to download the file. All you'd need to do is add a couple of lines of code after the download to send an email ( adding the code in blue )
Case "Download"
IncrementDownloads(e.CommandArgument)
Dim target As String = oRepositoryBusinessController.GetSkinAttribute(xmlDoc, "DOWNLOAD", "Target", "NEW")
oRepositoryBusinessController.DownloadFile(e.CommandArgument, target)
' get portal settings so you can get the admin's email address
Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
' construct your email body
Dim strBody as string = "On " & Date.Now() & " " & UserInfo.DisplayName & " downloaded " & objRepository.Filename
' send the email to the original author
DotNetNuke.Services.Mail.Mail.SendMail(_portalSettings.Email, objRepository.AuthorEmail, _
"", "", Services.Mail.MailPriority.Normal, "Someone has downloaded your File", _
Services.Mail.MailFormat.Text, System.Text.Encoding.Default, strBody, "", "", "", "", "")
|
Compile and test within Visual Studio to make sure it's working properly. Then re-compile one last time in Release mode. Then exit Visual Studio.
To re-package: Run the /DesktopModules/Repository/DotNetNuke.Repository.build batch file ( requires that you have NANT installed )
Look in the /DesktopModules/Repository/package folder and you'll see a new Install .zip that you can then use to install your new Repository module on any DotNetNuke installation, either 3.X or 4.X