diff --git a/.gitignore b/.gitignore index 3eb7d9a..d3b747f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,227 @@ -Installs/SimpleGallery.packagefolder/ +# The following command works for downloading when using Git for Windows: +# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore +# +# Download this file using PowerShell v3 under Windows with the following comand: +# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore +# +# or wget: +# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Bb]in/ +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ +# build folder is nowadays used for build scripts and should not be ignored +#build/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# OS generated files # +.DS_Store* +Icon? + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# Temp files when opening LibreOffice on ubuntu +.~lock.* + +# svn +.svn + +# CVS - Source Control +**/CVS/ + +# Remainings from resolving conflicts in Source Control +*.orig + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide + +# Visual Studio temp something +.vs/ + +# dotnet stuff +project.lock.json + +# VS 2015+ +*.vc.vc.opendb +*.vc.db + +# Rider +.idea/ + +# Visual Studio Code +.vscode/ + +# Output folder used by Webpack or other FE stuff +**/node_modules/* +**/wwwroot/* + +# SpecFlow specific +*.feature.cs +*.feature.xlsx.* +*.Specs_*.html + +##### +# End of core ignore list, below put you custom 'per project' settings (patterns or path) +##### +.vs/ \ No newline at end of file diff --git a/.vs/Ventrian.SimpleGallery/v15/.suo b/.vs/Ventrian.SimpleGallery/v15/.suo new file mode 100644 index 0000000..69971a1 Binary files /dev/null and b/.vs/Ventrian.SimpleGallery/v15/.suo differ diff --git a/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/db.lock b/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/db.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide b/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide new file mode 100644 index 0000000..7f51b28 Binary files /dev/null and b/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide-shm b/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide-shm new file mode 100644 index 0000000..494d0f2 Binary files /dev/null and b/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide-wal b/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide-wal new file mode 100644 index 0000000..f3c009e Binary files /dev/null and b/.vs/Ventrian.SimpleGallery/v15/Server/sqlite3/storage.ide-wal differ diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 0000000..9639b65 --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1020 @@ + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AddPhoto.ascx b/AddPhoto.ascx index 95fcfa3..c2f8a6d 100755 --- a/AddPhoto.ascx +++ b/AddPhoto.ascx @@ -4,6 +4,560 @@ <%@ Register TagPrefix="SimpleGallery" TagName="EditPhotos" Src="Controls\EditPhotos.ascx" %> + + +<%----%> + + + + + + + +<%----%> +<%----%> + + + + + + + + +
@@ -77,14 +631,52 @@
- - + + + + + + + + +
+ +
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + +
+ + + + +
+ +
- - - - -
@@ -94,13 +686,23 @@

+ + + - - + + <% If pnlStep2.Visible = True Then%> + + + + <% Else %> + + + <% End If %>
diff --git a/AddPhoto.ascx.designer.vb b/AddPhoto.ascx.designer.vb index 14ae294..818f7b8 100755 --- a/AddPhoto.ascx.designer.vb +++ b/AddPhoto.ascx.designer.vb @@ -23,6 +23,15 @@ Namespace Ventrian.SimpleGallery ''' Protected WithEvents ucGalleryMenu As Global.Ventrian.SimpleGallery.Controls.GalleryMenu + ''' + '''exifScripts control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents exifScripts As Global.System.Web.UI.WebControls.PlaceHolder + ''' '''imgStep control. ''' @@ -230,6 +239,15 @@ Namespace Ventrian.SimpleGallery ''' Protected WithEvents fupFile As Global.System.Web.UI.WebControls.FileUpload + ''' + '''rexp control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents rexp As Global.System.Web.UI.WebControls.RegularExpressionValidator + ''' '''btnUploadFiles control. ''' @@ -239,6 +257,15 @@ Namespace Ventrian.SimpleGallery ''' Protected WithEvents btnUploadFiles As Global.System.Web.UI.WebControls.Button + ''' + '''Button1 control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents Button1 As Global.System.Web.UI.WebControls.Button + ''' '''addedPhotosRepeater control. ''' @@ -302,6 +329,33 @@ Namespace Ventrian.SimpleGallery ''' Protected WithEvents cmdCancel As Global.System.Web.UI.WebControls.LinkButton + ''' + '''LinkButton1 control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents LinkButton1 As Global.System.Web.UI.WebControls.LinkButton + + ''' + '''ImageButton1 control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents ImageButton1 As Global.System.Web.UI.WebControls.ImageButton + + ''' + '''cmdNext2 control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents cmdNext2 As Global.System.Web.UI.WebControls.Button + ''' '''cmdNext control. ''' diff --git a/AddPhoto.ascx.vb b/AddPhoto.ascx.vb index 8710cbb..6eadaa4 100755 --- a/AddPhoto.ascx.vb +++ b/AddPhoto.ascx.vb @@ -27,12 +27,15 @@ Namespace Ventrian.SimpleGallery Partial Public Class AddPhoto Inherits SimpleGalleryBase + + #Region " Private Members " Private _albumID As Integer = Null.NullInteger Private _selAlbumID As Integer = Null.NullInteger Private _returnUrl As String = Null.NullString Private _batchID As String = Null.NullString + Private _tempbatchID As String = Null.NullString #End Region @@ -167,6 +170,12 @@ Namespace Ventrian.SimpleGallery _batchID = Request("BatchID") End If + If (Request("TBatchID") <> "") Then + _tempbatchID = Request("TBatchID") + End If + + + End Sub Private Sub SecurityCheck() @@ -204,6 +213,33 @@ Namespace Ventrian.SimpleGallery If (HttpContext.Current.Items("SimpleGallery-ScriptsRegistered") Is Nothing) Then + + 'If (HttpContext.Current.Items("jquery_registered") Is Nothing) Then ' And HttpContext.Current.Items("jQueryRequested") Is Nothing And SimpleGalleryBase.GallerySettings.IncludeJQuery) Then + + 'Dim litLink As New Literal + 'litLink.Text = "" & vbCrLf _ + ' & "" & vbCrLf + 'imageToolsScripts.Controls.Add(litLink) + + + 'Dim litLink2 As New Literal + 'litLink2.Text = "" & vbCrLf _ + ' & "" & vbCrLf + 'exifScripts.Controls.Add(litLink2) + + 'Page.ClientScript.RegisterStartupScript(Me.GetType(), "VentrianGallery", litLink.Text.ToString()) + + 'Else + + ' Dim litLink As New Literal + ' litLink.Text = "" & vbCrLf _ + ' & "" & vbCrLf + ' 'Page.Header.Controls.Add(litLink) + ' phjQueryScripts.Controls.Add(litLink) + ' 'Page.ClientScript.RegisterStartupScript(Me.GetType(), "VentrianGallery", litLink.Text.ToString()) + + 'End If + HttpContext.Current.Items.Add("SimpleGallery-ScriptsRegistered", "true") End If @@ -217,11 +253,17 @@ Namespace Ventrian.SimpleGallery Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try - SecurityCheck() ReadQueryString() BindBreadCrumbs() + If (_tempbatchID = Null.NullString) Then + litBatchID.Value = System.Guid.NewGuid().ToString() + _tempbatchID = litBatchID.Value + Else + litBatchID.Value = _tempbatchID + End If + If Me.GallerySettings.PhotoModeration AndAlso (Me.HasEditPermissions() Or Me.HasEditPhotoPermissions Or Me.HasApprovePhotoPermissions) = False Then lblRequiresApproval.Visible = True End If @@ -276,7 +318,7 @@ Namespace Ventrian.SimpleGallery lblStep.Text = Localization.GetString("Step2", Me.LocalResourceFile) lblStepDescription.Text = Localization.GetString("Step2Description", Me.LocalResourceFile) - litBatchID.Value = System.Guid.NewGuid().ToString() + litBatchID.Value = If(_tempbatchID = Null.NullString, System.Guid.NewGuid().ToString(), _tempbatchID) Else pnlStep1.Visible = False @@ -314,9 +356,9 @@ Namespace Ventrian.SimpleGallery If (drpAlbums.SelectedValue <> "-1" And rdoCreateNew.Checked = False) Then If (_returnUrl <> "") Then - Response.Redirect(EditUrl("AlbumID", drpAlbums.SelectedValue, "Add", "ReturnUrl=" & System.Uri.EscapeDataString(_returnUrl)), True) + Response.Redirect(EditUrl("AlbumID", drpAlbums.SelectedValue, "Add", "ReturnUrl=" & System.Uri.EscapeDataString(_returnUrl), "TBatchID=" & litBatchID.Value), True) Else - Response.Redirect(EditUrl("AlbumID", drpAlbums.SelectedValue, "Add"), True) + Response.Redirect(EditUrl("AlbumID", drpAlbums.SelectedValue, "Add", "TBatchID=" & litBatchID.Value), True) End If Else @@ -329,6 +371,7 @@ Namespace Ventrian.SimpleGallery objAlbum.Caption = txtCaption.Text objAlbum.Description = txtDescription.Text objAlbum.IsPublic = True + objAlbum.InheritSecurity = True objAlbum.HomeDirectory = GallerySettings.AlbumDefaultPath objAlbum.AlbumID = objAlbumController.Add(objAlbum) @@ -336,9 +379,9 @@ Namespace Ventrian.SimpleGallery objAlbumController.Update(objAlbum) If (_returnUrl <> "") Then - Response.Redirect(EditUrl("AlbumID", objAlbum.AlbumID.ToString(), "Add", "ReturnUrl=" & System.Uri.EscapeDataString(_returnUrl)), True) + Response.Redirect(EditUrl("AlbumID", objAlbum.AlbumID.ToString(), "Add", "ReturnUrl=" & System.Uri.EscapeDataString(_returnUrl), "TBatchID=" & litBatchID.Value), True) Else - Response.Redirect(EditUrl("AlbumID", objAlbum.AlbumID.ToString(), "Add"), True) + Response.Redirect(EditUrl("AlbumID", objAlbum.AlbumID.ToString(), "Add", "TBatchID=" & litBatchID.Value), True) End If End If @@ -413,12 +456,13 @@ Namespace Ventrian.SimpleGallery End Sub - Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click, imgNext.Click + Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click, imgNext.Click, cmdNext2.Click MoveNext() End Sub + Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click, imgCancel.Click MoveCancel() @@ -689,9 +733,9 @@ Namespace Ventrian.SimpleGallery Dim allAddedPhotos As List(Of PhotoInfo) - If Not IsNothing(addedPhotosRepeater.DataSource) then + If Not IsNothing(addedPhotosRepeater.DataSource) Then allAddedPhotos = CType(addedPhotosRepeater.DataSource, List(Of PhotoInfo)) - Else + Else allAddedPhotos = New List(Of PhotoInfo)() End If @@ -707,6 +751,11 @@ Namespace Ventrian.SimpleGallery Dim fileNameWithoutExtension As String = RemoveExtension(fileName).Replace("/", "_").Replace(".", "_").Replace("%", "_").Replace("+", "") fileName = fileNameWithoutExtension & "." & fileExtension + 'prevent overwriting existing files + If File.Exists(filePath & fileName) = True Then + fileNameWithoutExtension = Guid.NewGuid.ToString() + fileName = fileNameWithoutExtension & "." & fileExtension + End If objFile.SaveAs(filePath & fileName) @@ -792,7 +841,7 @@ Namespace Ventrian.SimpleGallery objPhoto.ApproverID = UserId End If - objPhoto.BatchID = _batchID + objPhoto.BatchID = litBatchID.Value objPhoto.PhotoID = objPhotoController.Add(objPhoto) If (objPhoto.Tags <> "") Then @@ -873,6 +922,8 @@ Namespace Ventrian.SimpleGallery addedPhotosRepeater.DataSource = allAddedPhotos addedPhotosRepeater.DataBind() + btnUploadFiles.Enabled = True + Catch exc As Exception 'Module failed to load Dim objEventLog As New EventLogController If (exc.InnerException IsNot Nothing) Then @@ -891,8 +942,48 @@ Namespace Ventrian.SimpleGallery Dim img As Image = CType(e.Item.FindControl("addedPhoto"), Image) img.ImageUrl = Me.ResolveUrl("ImageHandler.ashx?width=" & GetPhotoWidth(e.Item.DataItem) & "&height=" & GetPhotoHeight(e.Item.DataItem) & "&HomeDirectory=" & System.Uri.EscapeDataString(DotNetNuke.Common.Globals.ApplicationPath + "/" + PortalSettings.HomeDirectory + "/" & objPhoto.HomeDirectory) & "&fileName=" & System.Uri.EscapeDataString(objPhoto.FileName) & "&portalid=" & PortalId.ToString() & "&i=" & objPhoto.PhotoID) + + Dim filePath As String = GetFilePath(objPhoto.AlbumID) + Dim rotatelink As LinkButton = CType(e.Item.FindControl("cmdrotate"), LinkButton) + rotatelink.CommandArgument = objPhoto.PhotoID End If End Sub + + Protected Sub addedPhotosRepeater_ItemCommand(source As Object, e As RepeaterCommandEventArgs) + + Try + Dim objPhoto As New PhotoInfo + Dim objPhotoController As New PhotoController + If Not (Null.IsNull(e.CommandArgument)) Then + objPhoto = objPhotoController.Get(e.CommandArgument) + If Not (objPhoto Is Nothing) Then + Dim originalFileName As String = objPhoto.FileName + Dim originalFilePath As String = GetFilePath(objPhoto.AlbumID) + Dim fileExtension As String = ExtractFileExtension(originalFileName) + Using photo As Drawing.Image = Drawing.Image.FromFile(originalFilePath & originalFileName) + photo.RotateFlip(Drawing.RotateFlipType.Rotate90FlipNone) + Select Case fileExtension.ToLower() + Case "jpg", "jpeg" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Jpeg) + Case "gif" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Gif) + Case "png" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Png) + Case "bmp" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Bmp) + Case Else + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Jpeg) + End Select + photo.Dispose() + End Using + End If + End If + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try + + + End Sub End Class End Namespace \ No newline at end of file diff --git a/Controls/EditPhotos.ascx b/Controls/EditPhotos.ascx index 4baada8..51d065d 100755 --- a/Controls/EditPhotos.ascx +++ b/Controls/EditPhotos.ascx @@ -1,7 +1,7 @@ <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="EditPhotos.ascx.vb" Inherits="Ventrian.SimpleGallery.Controls.EditPhotos" %> <%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> - - - - - - - - - - - << Prev       - Next >> - - - +<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ViewPhotos.ascx.vb" Inherits="Ventrian.SimpleGallery.Controls.ViewPhotos" %> + + + + + + + + + + + + + + + + + + + + + << Prev +    + +    + Next >> + + + diff --git a/Controls/ViewPhotos.ascx.designer.vb b/Controls/ViewPhotos.ascx.designer.vb index 5b8e852..8d332a5 100755 --- a/Controls/ViewPhotos.ascx.designer.vb +++ b/Controls/ViewPhotos.ascx.designer.vb @@ -1,21 +1,19 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:2.0.50727.5448 ' ' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' the code is regenerated. ' '------------------------------------------------------------------------------ Option Strict On Option Explicit On - Namespace Ventrian.SimpleGallery.Controls - + Partial Public Class ViewPhotos - + ''' '''phPopupScripts control. ''' @@ -24,7 +22,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phPopupScripts As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''phjQueryScripts control. ''' @@ -33,7 +31,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phjQueryScripts As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''phLightboxScripts control. ''' @@ -42,7 +40,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phLightboxScripts As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''phLightboxTop control. ''' @@ -51,7 +49,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phLightboxTop As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''dlGallery control. ''' @@ -60,7 +58,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dlGallery As Global.System.Web.UI.WebControls.DataList - + ''' '''pnlPaging control. ''' @@ -69,7 +67,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents pnlPaging As Global.System.Web.UI.WebControls.Panel - + ''' '''lnkPrev control. ''' @@ -78,7 +76,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lnkPrev As Global.System.Web.UI.WebControls.HyperLink - + ''' '''lblCurrentPage control. ''' @@ -87,7 +85,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblCurrentPage As Global.System.Web.UI.WebControls.Label - + ''' '''lnkNext control. ''' @@ -96,7 +94,7 @@ Namespace Ventrian.SimpleGallery.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lnkNext As Global.System.Web.UI.WebControls.HyperLink - + ''' '''phLightboxBottom control. ''' diff --git a/EditPhoto.ascx b/EditPhoto.ascx index 2d000b3..7111711 100755 --- a/EditPhoto.ascx +++ b/EditPhoto.ascx @@ -57,7 +57,8 @@ - + | + diff --git a/EditPhoto.ascx.designer.vb b/EditPhoto.ascx.designer.vb index c703281..4327c05 100755 --- a/EditPhoto.ascx.designer.vb +++ b/EditPhoto.ascx.designer.vb @@ -1,21 +1,19 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:2.0.50727.5448 ' ' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' the code is regenerated. ' '------------------------------------------------------------------------------ Option Strict On Option Explicit On - Namespace Ventrian.SimpleGallery - + Partial Public Class EditPhoto - + ''' '''ucGalleryMenu control. ''' @@ -24,7 +22,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents ucGalleryMenu As Global.Ventrian.SimpleGallery.Controls.GalleryMenu - + ''' '''pnlSettings control. ''' @@ -33,7 +31,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents pnlSettings As Global.System.Web.UI.WebControls.Panel - + ''' '''dshPhoto control. ''' @@ -42,7 +40,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshPhoto As Global.System.Web.UI.UserControl - + ''' '''lblPhotoSettingsHelp control. ''' @@ -51,7 +49,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblPhotoSettingsHelp As Global.System.Web.UI.WebControls.Label - + ''' '''tblPhoto control. ''' @@ -60,7 +58,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblPhoto As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''plAlbum control. ''' @@ -69,7 +67,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plAlbum As Global.System.Web.UI.UserControl - + ''' '''drpAlbums control. ''' @@ -78,7 +76,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents drpAlbums As Global.System.Web.UI.WebControls.DropDownList - + ''' '''cmdEditAlbums control. ''' @@ -87,7 +85,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdEditAlbums As Global.System.Web.UI.WebControls.LinkButton - + ''' '''valAlbums control. ''' @@ -96,7 +94,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents valAlbums As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''trName control. ''' @@ -105,7 +103,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents trName As Global.System.Web.UI.HtmlControls.HtmlTableRow - + ''' '''plName control. ''' @@ -114,7 +112,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plName As Global.System.Web.UI.UserControl - + ''' '''txtName control. ''' @@ -123,7 +121,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtName As Global.System.Web.UI.WebControls.TextBox - + ''' '''valName control. ''' @@ -132,7 +130,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents valName As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''trDescription control. ''' @@ -141,7 +139,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents trDescription As Global.System.Web.UI.HtmlControls.HtmlTableRow - + ''' '''plDescription control. ''' @@ -150,7 +148,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plDescription As Global.System.Web.UI.UserControl - + ''' '''txtDescription control. ''' @@ -159,7 +157,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtDescription As Global.System.Web.UI.WebControls.TextBox - + ''' '''trTags control. ''' @@ -168,7 +166,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents trTags As Global.System.Web.UI.HtmlControls.HtmlTableRow - + ''' '''plTags control. ''' @@ -177,7 +175,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plTags As Global.System.Web.UI.UserControl - + ''' '''txtTags control. ''' @@ -186,7 +184,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtTags As Global.System.Web.UI.WebControls.TextBox - + ''' '''plPhoto control. ''' @@ -195,7 +193,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plPhoto As Global.System.Web.UI.UserControl - + ''' '''phReplace control. ''' @@ -204,7 +202,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phReplace As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''litPhoto control. ''' @@ -213,7 +211,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litPhoto As Global.System.Web.UI.WebControls.Literal - + ''' '''cmdReplace control. ''' @@ -222,7 +220,16 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdReplace As Global.System.Web.UI.WebControls.LinkButton - + + ''' + '''cmdRotate90 control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents cmdRotate90 As Global.System.Web.UI.WebControls.LinkButton + ''' '''phReplaceUpload control. ''' @@ -231,7 +238,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phReplaceUpload As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''fuReplace control. ''' @@ -240,7 +247,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents fuReplace As Global.System.Web.UI.WebControls.FileUpload - + ''' '''chkAddAsBefore control. ''' @@ -249,7 +256,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents chkAddAsBefore As Global.System.Web.UI.WebControls.CheckBox - + ''' '''cmdUploadReplace control. ''' @@ -258,7 +265,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdUploadReplace As Global.System.Web.UI.WebControls.LinkButton - + ''' '''cmdCancelReplace control. ''' @@ -267,7 +274,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdCancelReplace As Global.System.Web.UI.WebControls.LinkButton - + ''' '''cmdUpdate control. ''' @@ -276,7 +283,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdUpdate As Global.System.Web.UI.WebControls.LinkButton - + ''' '''cmdCancel control. ''' @@ -285,7 +292,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdCancel As Global.System.Web.UI.WebControls.LinkButton - + ''' '''cmdDelete control. ''' @@ -294,7 +301,7 @@ Namespace Ventrian.SimpleGallery '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdDelete As Global.System.Web.UI.WebControls.LinkButton - + ''' '''cmdSetDefault control. ''' diff --git a/EditPhoto.ascx.vb b/EditPhoto.ascx.vb index 05c143a..61d3e97 100755 --- a/EditPhoto.ascx.vb +++ b/EditPhoto.ascx.vb @@ -573,6 +573,42 @@ Namespace Ventrian.SimpleGallery End Sub + Private Sub cmdRotate90_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRotate90.Click + Try + Dim objPhoto As New PhotoInfo + Dim objPhotoController As New PhotoController + If Not (Null.IsNull(_itemID)) Then + objPhoto = objPhotoController.Get(_itemID) + If Not (objPhoto Is Nothing) Then + If (objPhoto.AlbumID = Convert.ToInt32(drpAlbums.SelectedValue)) Then + Dim originalFileName As String = objPhoto.FileName + Dim originalFilePath As String = GetFilePath(objPhoto.AlbumID) + Dim fileExtension As String = ExtractFileExtension(originalFileName) + Using photo As Image = Drawing.Image.FromFile(originalFilePath & originalFileName) + photo.RotateFlip(Drawing.RotateFlipType.Rotate90FlipNone) + Select Case fileExtension.ToLower() + Case "jpg", "jpeg" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Jpeg) + Case "gif" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Gif) + Case "png" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Png) + Case "bmp" + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Bmp) + Case Else + photo.Save(originalFilePath & originalFileName, Drawing.Imaging.ImageFormat.Jpeg) + End Select + photo.Dispose() + End Using + End If + End If + End If + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try + + End Sub + Private Sub cmdUploadReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUploadReplace.Click If (fuReplace.HasFile) Then diff --git a/Uploader.aspx b/Uploader.aspx new file mode 100644 index 0000000..b33ab68 --- /dev/null +++ b/Uploader.aspx @@ -0,0 +1 @@ +<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Uploader.aspx.vb" Inherits="Ventrian.SimpleGallery.Uploader" %> diff --git a/Uploader.aspx.designer.vb b/Uploader.aspx.designer.vb new file mode 100644 index 0000000..c60681e --- /dev/null +++ b/Uploader.aspx.designer.vb @@ -0,0 +1,25 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.312 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + +Namespace Ventrian.SimpleGallery + + ''' + '''Uploader class. + ''' + ''' + '''Auto-generated class. + ''' + Partial Public Class Uploader + End Class +End Namespace diff --git a/Uploader.aspx.vb b/Uploader.aspx.vb new file mode 100644 index 0000000..911ee29 --- /dev/null +++ b/Uploader.aspx.vb @@ -0,0 +1,826 @@ +' +' Simple Gallery for DotNetNuke - http://www.dotnetnuke.com +' Copyright (c) 2002-2007 +' by Ventrian ( sales@ventrian.com ) ( http://www.ventrian.com ) +' + +Imports System.Drawing +Imports System.Drawing.Imaging +Imports System.IO + +Imports DotNetNuke.Common +Imports DotNetNuke.Common.Utilities +Imports DotNetNuke.Entities.Modules +Imports DotNetNuke.Entities.Portals +Imports DotNetNuke.Entities.Tabs +Imports DotNetNuke.Entities.Users +Imports DotNetNuke.Security +Imports DotNetNuke.Security.Roles +Imports DotNetNuke.Services.FileSystem + +Imports Ventrian.SimpleGallery.Common +Imports Ventrian.SimpleGallery.Entities +Imports DotNetNuke.Services.Log.EventLog +Imports DotNetNuke.Security.Permissions + +Imports Ventrian.ImageResizer + +Namespace Ventrian.SimpleGallery + + Partial Public Class Uploader + Inherits SimpleGalleryPageBase + +#Region " Private Members " + + Private _moduleConfiguration As ModuleInfo + Private _moduleID As Integer = Null.NullInteger + Private _tabModuleID As Integer = Null.NullInteger + Private _tabID As Integer = Null.NullInteger + Private _portalID As Integer = Null.NullInteger + Private _ticket As String = Null.NullString + Private _userID As Integer = Null.NullInteger + + Private _settings As Hashtable + Private _portal As PortalInfo + Private _tab As TabInfo + +#End Region + +#Region " Private Properties " + + Private ReadOnly Property Tab() As TabInfo + Get + If (_tab Is Nothing) Then + Dim objTabController As New TabController + _tab = objTabController.GetTab(_tabID, _portalID, False) + End If + Return _tab + End Get + End Property + + Private ReadOnly Property Portal() As PortalInfo + + Get + + If (_portal Is Nothing) Then + Dim objPortalController As New PortalController + _portal = objPortalController.GetPortal(_portalID) + End If + Return _portal + + End Get + + End Property + + Private ReadOnly Property UploadSettings() As GallerySettings + + Get + + Return Me.GallerySettings(Settings) + + End Get + + End Property + + Private ReadOnly Property ModuleConfiguration() As ModuleInfo + + Get + + If _moduleConfiguration Is Nothing Then + + Dim objModule As New ModuleController + _moduleConfiguration = objModule.GetModule(_moduleID, _tabID, False) + + End If + + Return _moduleConfiguration + End Get + + End Property + + Private ReadOnly Property Settings() As Hashtable + + Get + + If _settings Is Nothing Then + + Dim objModuleController As New ModuleController + + _settings = ModuleController.Instance.GetModule(_moduleID, -1, False).ModuleSettings 'objModuleController.GetModuleSettings(_moduleID) + _settings = GetTabModuleSettings(_tabModuleID, _settings) + + End If + + Return _settings + End Get + + End Property + + Private Function GetTabModuleSettings(ByVal TabModuleId As Integer, ByVal settings As Hashtable) As Hashtable + + Dim dr As IDataReader = DotNetNuke.Data.DataProvider.Instance().GetTabModuleSettings(TabModuleId) + + While dr.Read() + + If Not dr.IsDBNull(1) Then + settings(dr.GetString(0)) = dr.GetString(1) + Else + settings(dr.GetString(0)) = "" + End If + + End While + + dr.Close() + + Return settings + + End Function + +#End Region + + Public Class MemoryFile + Inherits HttpPostedFileBase + + Private _stream As Stream + Private _contentType As String + Private _fileName As String + + Public Sub New(ByVal stream As Stream, ByVal contentType As String, ByVal fileName As String) + Me._stream = stream + Me._contentType = contentType + Me._fileName = fileName + End Sub + + Public Sub SetStream(ByVal stream As Stream) + Me._stream = stream + End Sub + + Public Overrides ReadOnly Property ContentLength As Integer + Get + Return CInt(_stream.Length) + End Get + End Property + + Public Overrides ReadOnly Property ContentType As String + Get + Return _contentType + End Get + End Property + + Public Overrides ReadOnly Property FileName As String + Get + Return _fileName + End Get + End Property + + Public Overrides ReadOnly Property InputStream As Stream + Get + Return _stream + End Get + End Property + + Public Overrides Sub SaveAs(ByVal filename As String) + Dim fs As New FileStream(filename, FileMode.Create) + _stream.CopyTo(fs) + End Sub + End Class +#Region " Private Methods " + + Private Sub AuthenticateUserFromTicket() + + If (_ticket <> "") Then + + Dim ticket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(_ticket) + Dim fi As FormsIdentity = New FormsIdentity(ticket) + + Dim roles As String() = Nothing + HttpContext.Current.User = New System.Security.Principal.GenericPrincipal(fi, roles) + + Dim objUser As UserInfo = UserController.GetUserByName(_portalID, HttpContext.Current.User.Identity.Name) + + If Not (objUser Is Nothing) Then + _userID = objUser.UserID + HttpContext.Current.Items("UserInfo") = objUser + + + + Dim objRoleController As New RoleController + Dim lRoles As IList(Of DotNetNuke.Entities.Users.UserRoleInfo) = objRoleController.GetUserRoles(objUser, True) + Dim _myroles As New ArrayList + For Each role As DotNetNuke.Entities.Users.UserRoleInfo In lRoles + _myroles.Add(role.RoleName) + Next + 'roles = objRoleController.GetRolesByUser(_userID, _portalID) + roles = _myroles.ToArray() + + Dim strPortalRoles As String = Join(roles, New Char() {";"c}) + Context.Items.Add("UserRoles", ";" + strPortalRoles + ";") + End If + + End If + + End Sub + + Private Function ExtractFileName(ByVal path As String) As String + + Dim extractPos As Integer = path.LastIndexOf("\") + 1 + Return path.Substring(extractPos, path.Length - extractPos) + + End Function + + Private Function ExtractFileExtension(ByVal fileName As String) As String + + Dim extension As String = "" + + If (fileName.Length > 0) Then + If (fileName.IndexOf("."c) <> -1) Then + If (fileName.LastIndexOf("."c) < fileName.Length) Then + extension = fileName.Substring(fileName.LastIndexOf("."c) + 1, fileName.Length - (fileName.LastIndexOf("."c) + 1)) + End If + End If + End If + + Return extension + + End Function + + Public Function GetApproverDistributionList() As Hashtable + + Dim userList As Hashtable = New Hashtable + + If (Me.Settings.Contains(Constants.SETTING_APPROVE_ROLES)) Then + + Dim roles As String = Settings(Constants.SETTING_APPROVE_ROLES).ToString() + Dim rolesArray() As String = roles.Split(Convert.ToChar(";")) + + For Each role As String In rolesArray + If (role.Length > 0) Then + Dim objRoleController As RoleController = New RoleController + Dim objRole As RoleInfo = objRoleController.GetRoleByName(_portalID, role) + + If Not (objRole Is Nothing) Then + Dim objUsers As IList(Of DotNetNuke.Entities.Users.UserInfo) = objRoleController.GetUsersByRole(_portalID, role) + For Each objUser As UserInfo In objUsers + If (userList.Contains(objUser.UserID) = False) Then + Dim objUserController As UserController = New UserController + Dim objSelectedUser As UserInfo = objUserController.GetUser(_portalID, objUser.UserID) + If Not (objSelectedUser Is Nothing) Then + If (objSelectedUser.Email.Length > 0) Then + userList.Add(objUser.UserID, objSelectedUser.Email) + End If + End If + End If + Next + End If + End If + Next + + End If + + Return userList + + End Function + + Private Function GetFilePath(ByVal albumID As Integer) As String + + Dim filePath As String = "" + + Dim objAlbumController As New AlbumController + Dim objAlbum As AlbumInfo = objAlbumController.Get(albumID) + + If Not (objAlbum Is Nothing) Then + filePath = Portal.HomeDirectoryMapPath & objAlbum.HomeDirectory & "\" + End If + + If Not (Directory.Exists(filePath)) Then + Directory.CreateDirectory(filePath) + End If + + Return filePath + + End Function + + Private Function GetPhotoHeight(ByVal dataItem As Object) As String + + Dim objPhoto As PhotoInfo = CType(dataItem, PhotoInfo) + + If Not (objPhoto Is Nothing) Then + Dim width As Integer + If (objPhoto.Width > UploadSettings.ThumbnailWidth) Then + width = UploadSettings.ThumbnailWidth + Else + width = objPhoto.Width + End If + + Dim height As Integer = Convert.ToInt32(objPhoto.Height / (objPhoto.Width / width)) + If (height > UploadSettings.ThumbnailHeight) Then + height = UploadSettings.ThumbnailHeight + width = Convert.ToInt32(objPhoto.Width / (objPhoto.Height / height)) + End If + + Return height.ToString() + Else + Return UploadSettings.ThumbnailWidth.ToString() + End If + + End Function + + Private Function GetPhotoWidth(ByVal dataItem As Object) As String + + Dim objPhoto As PhotoInfo = CType(dataItem, PhotoInfo) + + If Not (objPhoto Is Nothing) Then + Dim width As Integer + If (objPhoto.Width > UploadSettings.ThumbnailWidth) Then + width = UploadSettings.ThumbnailWidth + Else + width = objPhoto.Width + End If + + Dim height As Integer = Convert.ToInt32(objPhoto.Height / (objPhoto.Width / width)) + If (height > UploadSettings.ThumbnailHeight) Then + height = UploadSettings.ThumbnailHeight + width = Convert.ToInt32(objPhoto.Width / (objPhoto.Height / height)) + End If + + Return width.ToString() + Else + Return UploadSettings.ThumbnailWidth.ToString() + End If + + End Function + + Private Function HasApproval() As Boolean + + If (Me.HasEditPermissions Or Me.HasEditPhotoPermissions Or Me.HasApprovePhotoPermissions) Then + Return True + End If + + 'If (IsInRoles(ModuleConfiguration.AuthorizedEditRoles) Or IsInRoles(Tab.AdministratorRoles) Or IsInRoles(Portal.AdministratorRoleName)) Then + If HasEditPermissions() Then + Return True + End If + + If (Settings.Contains(Constants.SETTING_EDIT_ROLES)) Then + If (IsInRoles(Settings(Constants.SETTING_EDIT_ROLES).ToString())) Then + Return True + End If + End If + + If (Settings.Contains(Constants.SETTING_APPROVE_ROLES)) Then + If (IsInRoles(Settings(Constants.SETTING_APPROVE_ROLES).ToString())) Then + Return True + End If + End If + + End Function + + Public Function HasApprovePhotoPermissions() As Boolean + + If (HasEditPermissions()) Then + Return True + End If + + If (Settings.Contains(Constants.SETTING_APPROVE_ROLES)) Then + Return PortalSecurity.IsInRoles(Settings(Constants.SETTING_APPROVE_ROLES).ToString()) + Else + Return False + End If + + End Function + + Public Function HasEditPermissions() As Boolean + + Return ModulePermissionController.CanEditModuleContent(ModuleConfiguration) + + 'Return _ + ' (PortalSecurity.IsInRoles(ModuleConfiguration.AuthorizedEditRoles) = True) Or + ' (PortalSecurity.IsInRoles(Tab.AdministratorRoles) = True) Or + ' (PortalSecurity.IsInRoles(Portal.AdministratorRoleName) = True) + + End Function + + Public Function HasEditPhotoPermissions() As Boolean + + If (HasEditPermissions()) Then + Return True + End If + + If (Settings.Contains(Constants.SETTING_EDIT_ROLES)) Then + Return PortalSecurity.IsInRoles(Settings(Constants.SETTING_EDIT_ROLES).ToString()) + Else + Return False + End If + + End Function + + Private Function IsInRole(ByVal role As String) As Boolean + + Dim objUserInfo As UserInfo = UserController.Instance.GetCurrentUserInfo() + Dim context As HttpContext = HttpContext.Current + + If (role <> "" AndAlso Not role Is Nothing AndAlso ((context.Request.IsAuthenticated = False And role = glbRoleUnauthUserName))) Then + Return True + Else + Dim roles As String = CType(context.Items("UserRoles"), String) + If Not roles Is Nothing Then + Dim rolesArr As String() = roles.Split(";"c) + For Each strRole As String In rolesArr + If strRole = role Then + Return True + End If + Next + End If + Return False + End If + + End Function + + Private Function IsInRoles(ByVal roles As String) As Boolean + + If Not roles Is Nothing Then + Dim context As HttpContext = HttpContext.Current + Dim objUserInfo As UserInfo = UserController.Instance.GetCurrentUserInfo() + Dim role As String + + For Each role In roles.Split(New Char() {";"c}) + If objUserInfo.IsSuperUser Or (role <> "" AndAlso Not role Is Nothing AndAlso + (role = glbRoleAllUsersName Or + IsInRole(role) = True + )) Then + Return True + End If + Next role + + End If + + Return False + + End Function + + Private Sub ReadQueryString() + + If (Request("ModuleID") <> "") Then + _moduleID = Convert.ToInt32(Request("ModuleID")) + End If + + If (Request("PortalID") <> "") Then + _portalID = Convert.ToInt32(Request("PortalID")) + End If + + If (Request("TabID") <> "") Then + _tabID = Convert.ToInt32(Request("TabID")) + End If + + If (Request("Ticket") <> "") Then + _ticket = Request("Ticket") + End If + + End Sub + + Private Function RemoveExtension(ByVal fileName As String) As String + + Dim name As String = "" + + If (fileName.Length > 0) Then + If (fileName.IndexOf("."c) <> -1) Then + name = fileName.Substring(0, fileName.LastIndexOf("."c)) + End If + End If + + Return name + + End Function + +#End Region + +#Region " Event Handlers " + + Private Function convertbytetoimage(ByVal BA As Byte()) + Dim ms As MemoryStream = New MemoryStream(BA) + Dim image = System.Drawing.Image.FromStream(ms) + Return image + End Function + + Private Function ToStream(ByVal image As Image, ByVal format As ImageFormat) As Stream + Dim stream = New System.IO.MemoryStream() + image.Save(stream, format) + stream.Position = 0 + Return stream + End Function + + Private Function FromString(ByVal format As String) As ImageFormat + Select Case format + Case "image/jpg", "image/jpeg" : Return ImageFormat.Jpeg + Case "image/gif" : Return ImageFormat.Gif + Case "image/png" : Return ImageFormat.Png + Case Else : Return ImageFormat.Jpeg + End Select + + End Function + + Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + + Try + + ReadQueryString() + AuthenticateUserFromTicket() + + If (Request.IsAuthenticated = False) Then + Response.Write("-2") + Response.End() + End If + + Dim objUser As UserInfo = UserController.GetUserByName(_portalID, HttpContext.Current.User.Identity.Name) + + If Not (objUser Is Nothing) Then + _userID = objUser.UserID + Else + Response.Write("-2") + Response.End() + End If + + Dim Fdata As String = "" + If (Request("Fdata") <> "") Then + Fdata = Request("Fdata") + End If + + Dim myFileName As String = "" + If (Request("FileName") <> "") Then + myFileName = Request("FileName") + End If + + Dim myContentType As String = "" + If (Request("ContentType") <> "") Then + myContentType = Request("ContentType") + End If + + + + + Dim byteresponse As Byte() = Convert.FromBase64String(Fdata) + + Dim img1 As System.Drawing.Image = convertbytetoimage(byteresponse) + + 'Dim stream2 As MemoryStream = New MemoryStream(byteresponse) + Dim stream2 As MemoryStream = ToStream(img1, FromString(myContentType)) + + 'Dim tream As Stream = Request.InputStream + 'Dim bytes As Byte() = New Byte(tream.Length) {} + 'tream.Position = 0 + 'tream.Read(bytes, 0, DirectCast(tream.Length, Long)) + 'Dim data As String = Encoding.ASCII.GetString(bytes) ' this is your string + + 'Dim js As Script.Serialization.JavaScriptSerializer = New Script.Serialization.JavaScriptSerializer() + 'Dim root As fileInfo = js.Deserialize(Of fileInfo)(fdata1) + + + ' Dim fdata As fileInfo = CType(fdata1, fileInfo) + ' Dim objFile As HttpPostedFile = Request.Files("Filedata") + 'Dim objFile As HttpPostedFile = Request.Files("Filedata") + Dim objFile As MemoryFile = New MemoryFile(stream2, myContentType, myFileName) + + If Not (objFile Is Nothing) Then + + Dim objPortalController As New PortalController() + If (objPortalController.HasSpaceAvailable(_portalID, objFile.ContentLength) = False) Then + Response.Write("-1") + Response.End() + End If + + Dim albumID As Integer = Convert.ToInt32(Request("AlbumID")) + Dim batchID As String = Request("BatchID") + + Dim fileName As String = ExtractFileName(objFile.FileName) + Dim fileExtension As String = ExtractFileExtension(fileName) + Dim fileNameWithoutExtension As String = RemoveExtension(fileName).Replace("/", "_").Replace(".", "_").Replace("%", "_").Replace("+", "") + + fileName = fileNameWithoutExtension & "." & fileExtension + + Dim filePath As String = GetFilePath(albumID) + + If (File.Exists(filePath & fileName)) Then + For i As Integer = 1 To 1000 + If Not (File.Exists(filePath & fileNameWithoutExtension & "_" & i.ToString() & "." & fileExtension)) Then + fileName = fileNameWithoutExtension & "_" & i.ToString() & "." & fileExtension + fileNameWithoutExtension = fileNameWithoutExtension & "_" & i.ToString() + Exit For + End If + Next + End If + + Dim objQueryString As New NameValueCollection() + objQueryString.Add("maxwidth", UploadSettings.ImageWidth.ToString()) + objQueryString.Add("maxheight", UploadSettings.ImageHeight.ToString()) + + 'objFile.SaveAs(filePath & fileName) + img1.Save(filePath & fileName, FromString(myContentType)) + + Dim buff As Byte() = System.IO.File.ReadAllBytes(filePath & fileName) + Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(buff) + ms.Position = 0 + objFile.SetStream(ms) + + + + Dim resize As Boolean = False + Dim photo As Drawing.Image = Drawing.Image.FromStream(objFile.InputStream) + + If (UploadSettings.ImageWidth < photo.Width Or UploadSettings.ImageHeight < photo.Height) Then + resize = True + End If + + Dim objWatermarkSettings As New WatermarkSettings(Request.QueryString) + If (UploadSettings.UseWatermark And UploadSettings.WatermarkText <> "") Then + objWatermarkSettings.WatermarkText = UploadSettings.WatermarkText + End If + If (UploadSettings.UseWatermark And UploadSettings.WatermarkImage <> "") Then + objWatermarkSettings.WatermarkImagePath = (PortalSettings.HomeDirectoryMapPath & UploadSettings.WatermarkImage) + objWatermarkSettings.WatermarkImagePosition = UploadSettings.WatermarkImagePosition + End If + + Dim target As String = filePath & fileName + If (resize And UploadSettings.ResizePhoto) Then + ImageManager.getBestInstance().BuildImage(filePath & fileName, target, objQueryString, objWatermarkSettings) + End If + + Dim width As Integer = photo.Width + Dim height As Integer = photo.Height + + If (UploadSettings.ResizePhoto) Then + + If (width > UploadSettings.ImageWidth) Then + width = UploadSettings.ImageWidth + height = Convert.ToInt32(height / (photo.Width / UploadSettings.ImageWidth)) + End If + + If (height > UploadSettings.ImageHeight) Then + height = UploadSettings.ImageHeight + width = Convert.ToInt32(photo.Width / (photo.Height / UploadSettings.ImageHeight)) + End If + + End If + + photo.Dispose() + + Dim objPhoto As New PhotoInfo + Dim objPhotoController As New PhotoController + + objPhoto.Name = RemoveExtension(ExtractFileName(objFile.FileName)) + objPhoto.ModuleID = _moduleID + objPhoto.AlbumID = albumID + objPhoto.AuthorID = _userID + objPhoto.DateCreated = DateTime.Now + objPhoto.DateUpdated = objPhoto.DateCreated + + objPhoto.FileName = fileNameWithoutExtension & "." & fileExtension + objPhoto.Width = width + objPhoto.Height = height + + Try + If UploadSettings.UseXmpExif Then + Dim objXmpReader As New Entities.MetaData.XmpReader() + objXmpReader.ApplyAttributes(objPhoto, objFile.InputStream) + End If + Catch + ' Many things can go wrong here, so just ignore if we can't extract XMP data. + End Try + + DataCache.RemoveCache("SG-Album-Zip-" & albumID) + + ' Clear Zip Cache + Dim objAlbumController As New AlbumController() + Dim objAlbum As AlbumInfo = objAlbumController.Get(albumID) + + While (objAlbum IsNot Nothing) + DataCache.RemoveCache("SG-Album-Zip-" & objAlbum.AlbumID.ToString()) + objAlbum = objAlbumController.Get(objAlbum.ParentAlbumID) + End While + + If (UploadSettings.PhotoModeration) Then + If (HasApproval()) Then + objPhoto.IsApproved = True + objPhoto.DateApproved = objPhoto.DateCreated + objPhoto.ApproverID = _userID + Else + objPhoto.IsApproved = False + objPhoto.DateApproved = Null.NullDate + objPhoto.ApproverID = Null.NullInteger + End If + Else + objPhoto.IsApproved = True + objPhoto.DateApproved = objPhoto.DateCreated + objPhoto.ApproverID = _userID + End If + + objPhoto.BatchID = batchID + objPhoto.PhotoID = objPhotoController.Add(objPhoto) + + If (objPhoto.Tags <> "") Then + Dim tags As String() = objPhoto.Tags.Split(","c) + For Each tag As String In tags + If (tag <> "") Then + Dim objTagController As New TagController + Dim objTag As TagInfo = objTagController.Get(_moduleID, tag.ToLower()) + + If (objTag Is Nothing) Then + objTag = New TagInfo + objTag.ModuleID = _moduleID + objTag.Name = tag + objTag.NameLowered = tag.ToLower() + objTag.Usages = 0 + objTag.TagID = objTagController.Add(objTag) + End If + + objTagController.Add(objPhoto.PhotoID, objTag.TagID) + End If + Next + End If + + ' Re-get the photo to get AlbumPath. + objPhoto = objPhotoController.Get(objPhoto.PhotoID) + + If (UploadSettings.Compression = CompressionType.MinSize) Then + Response.Write(Me.ResolveUrl("ImageHandler.ashx?width=" & GetPhotoWidth(CType(objPhoto, Object)) & "&height=" & GetPhotoHeight(CType(objPhoto, Object)) & "&HomeDirectory=" & System.Uri.EscapeDataString(DotNetNuke.Common.Globals.ApplicationPath + "/" + Portal.HomeDirectory + "/" & objPhoto.HomeDirectory) & "&fileName=" & System.Uri.EscapeDataString(objPhoto.FileName) & "&portalid=" & _portalID.ToString() & "&i=" & objPhoto.PhotoID)) + Else + Response.Write(Me.ResolveUrl("ImageHandler.ashx?width=" & GetPhotoWidth(CType(objPhoto, Object)) & "&height=" & GetPhotoHeight(CType(objPhoto, Object)) & "&HomeDirectory=" & System.Uri.EscapeDataString(DotNetNuke.Common.Globals.ApplicationPath + "/" + Portal.HomeDirectory + "/" & objPhoto.HomeDirectory) & "&fileName=" & System.Uri.EscapeDataString(objPhoto.FileName) & "&portalid=" & _portalID.ToString() & "&i=" & objPhoto.PhotoID & "&q=1")) + End If + + Try + + ' Update DNN File Meta Info + Dim strFileName As String = Path.GetFileName(filePath & fileName) + Dim strFolderpath As String = GetSubFolderPath(filePath & fileName, _portalID) + 'Dim finfo As New System.IO.FileInfo(filePath & fileName) + + 'Dim strContentType As String = "" + 'Dim strExtension As String = Path.GetExtension(fileName).Replace(".", "") + + 'Select Case strExtension + ' Case "jpg", "jpeg" : strContentType = "image/jpeg" + ' Case "gif" : strContentType = "image/gif" + ' Case "png" : strContentType = "image/png" + ' Case Else : strContentType = "application/octet-stream" + 'End Select + + 'Dim folderID As Integer = Null.NullInteger + 'Dim objFolderController As New FolderController + 'Dim folder As FolderInfo = objFolderController.GetFolder(_portalID, strFolderpath, False) + 'If (folder Is Nothing) Then + ' folderID = objFolderController.AddFolder(_portalID, strFolderpath) + 'Else + ' folderID = folder.FolderID + 'End If + + Dim folderID As Integer = Null.NullInteger + 'Dim objFolderController As New FolderController + Dim folder As FolderInfo = FolderManager.Instance.GetFolder(_portalID, strFolderpath) 'objFolderController.GetFolder(_portalID, strFolderpath, False) + If (folder Is Nothing) Then + 'folderID = objFolderController.AddFolder(_portalID, strFolderpath) + folder = FolderManager.Instance.AddFolder(_portalID, strFolderpath) + Else + folderID = folder.FolderID + End If + + 'Dim parentFolderPath As String = strFolderpath.Substring(0, strFolderpath.Substring(0, strFolderpath.Length - 1).LastIndexOf("/") + 1) + + ''Get Parents permissions + 'Dim objFolderPermissionController As New FolderPermissionController + 'Dim objFolderPermissions As FolderPermissionCollection + 'objFolderPermissions = objFolderPermissionController.GetFolderPermissionsCollectionByFolderPath(_portalID, parentFolderPath) + + ''Iterate parent permissions to see if permisison has already been added + 'For Each objPermission As FolderPermissionInfo In objFolderPermissions + ' FileSystemUtils.SetFolderPermission(_portalID, folderID, objPermission.PermissionID, objPermission.RoleID, objPermission.UserID, parentFolderPath) + 'Next + + 'If (strFileName.IndexOf("'") = -1) Then + ' Dim objFiles As New FileController + ' objFiles.AddFile(_portalID, strFileName, strExtension, finfo.Length, width, height, strContentType, strFolderpath, folderID, True) + 'End If + + Catch + End Try + + End If + + ' Response.End() + + + Catch exc As Exception 'Module failed to load + Response.Write("-3") + Dim objEventLog As New EventLogController + If (exc.InnerException IsNot Nothing) Then + objEventLog.AddLog("GalleryUploaderException", exc.InnerException.ToString(), PortalSettings, -1, EventLogController.EventLogType.ADMIN_ALERT) + End If + objEventLog.AddLog("GalleryUploaderException", exc.ToString(), PortalSettings, -1, EventLogController.EventLogType.ADMIN_ALERT) + Response.End() + End Try + + End Sub + +#End Region + + End Class + +End Namespace \ No newline at end of file diff --git a/Ventrian.SimpleGallery.vbproj b/Ventrian.SimpleGallery.vbproj index e23edb8..bd94be4 100755 --- a/Ventrian.SimpleGallery.vbproj +++ b/Ventrian.SimpleGallery.vbproj @@ -61,7 +61,7 @@ False Libraries\SharpZipLib.dll - False + True @@ -81,7 +81,7 @@ False Libraries\Ventrian.ImageResizer.dll - False + True @@ -179,6 +179,13 @@ ASPXCodeBehind + + Uploader.aspx + + + Uploader.aspx + ASPXCodeBehind + ViewCart.ashx @@ -587,6 +594,7 @@ + diff --git a/Ventrian.SimpleGallery.vbproj.user b/Ventrian.SimpleGallery.vbproj.user new file mode 100644 index 0000000..f30cf51 --- /dev/null +++ b/Ventrian.SimpleGallery.vbproj.user @@ -0,0 +1,39 @@ + + + + Debug|Any CPU + ShowAllFiles + false + + + + + + + + + + + + + + CurrentPage + True + False + False + False + + + + + + + + + True + True + + + + + \ No newline at end of file