parent
d3b4793113
commit
36cee77790
9 changed files with 84 additions and 19 deletions
|
|
@ -97,3 +97,14 @@ padding-top: 0px;
|
||||||
.modmedia_edit{
|
.modmedia_edit{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.not-singular .entry-content .private{
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: -6px;
|
||||||
|
right: 10px;
|
||||||
|
width: 74px;
|
||||||
|
height: 22px;
|
||||||
|
background: url("../img/private.png") no-repeat top left;
|
||||||
|
z-index: 200
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,12 @@
|
||||||
<%if( user.canEdit( folder ) && folder.getParent() != null ){ %>
|
<%if( user.canEdit( folder ) && folder.getParent() != null ){ %>
|
||||||
<form action="gallery?folder=<%=folder.getParent().getId() %>" method="post" align="right">
|
<form action="gallery?folder=<%=folder.getParent().getId() %>" method="post" align="right">
|
||||||
<input type="hidden" name="id" value="<%=folder.getId() %>">
|
<input type="hidden" name="id" value="<%=folder.getId() %>">
|
||||||
|
|
||||||
|
<%if( !folder.isPrivate() ){ %>
|
||||||
|
<button type="submit" name="action" value="mkprivate" ><img src="img/user-silhouette.png" style="width: 10px; padding-right: 5px;">Private</button>
|
||||||
|
<%}else{ %>
|
||||||
|
<button type="submit" name="action" value="mkprivate" ><img src="img/user-share.png" style="width: 10px; padding-right: 5px;">Public</button>
|
||||||
|
<%} %>
|
||||||
<button type="submit" name="action" value="rmdir" onClick="return confirm ('Are you sure you want to delete this folder?')"><img src="img/delete.png" style="width: 10px; padding-right: 5px;">Delete</button>
|
<button type="submit" name="action" value="rmdir" onClick="return confirm ('Are you sure you want to delete this folder?')"><img src="img/delete.png" style="width: 10px; padding-right: 5px;">Delete</button>
|
||||||
</form>
|
</form>
|
||||||
<%} %>
|
<%} %>
|
||||||
|
|
@ -27,9 +33,16 @@
|
||||||
for( Folder subfolder : ((List<Folder>)request.getAttribute("subfolders")) ){ %>
|
for( Folder subfolder : ((List<Folder>)request.getAttribute("subfolders")) ){ %>
|
||||||
<DIV class="entry-content">
|
<DIV class="entry-content">
|
||||||
<DIV class="entry-content">
|
<DIV class="entry-content">
|
||||||
<%if( subfolder.getDate().after(new Timestamp(System.currentTimeMillis()-10*24*60*60*1000) )){ %><SPAN class="new"></SPAN><%} %>
|
<%if( subfolder.isPrivate() ){ %>
|
||||||
<A href="gallery?folder=<%=subfolder.getId()%>"><SPAN class="slide-title" style="opacity: 0; "><%=subfolder.getName()%></SPAN>
|
<SPAN class="private"></SPAN>
|
||||||
<IMG class="thumbnail" src="img/folder.png" width="125" height="125" alt="<%=subfolder.getName()%>"><SPAN class="cover-up"></SPAN></A>
|
<%} else if( subfolder.getDate().after(new Timestamp(System.currentTimeMillis()-10*24*60*60*1000) )){ %>
|
||||||
|
<SPAN class="new"></SPAN>
|
||||||
|
<%} %>
|
||||||
|
<A href="gallery?folder=<%=subfolder.getId()%>">
|
||||||
|
<SPAN class="slide-title" style="opacity: 0; "><%=subfolder.getName()%></SPAN>
|
||||||
|
<IMG class="thumbnail" src="img/folder.png" width="125" height="125" alt="<%=subfolder.getName()%>">
|
||||||
|
<SPAN class="cover-up"></SPAN
|
||||||
|
></A>
|
||||||
</DIV>
|
</DIV>
|
||||||
</DIV><!-- .post -->
|
</DIV><!-- .post -->
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
|
||||||
BIN
WebContent/img/private.png
Normal file
BIN
WebContent/img/private.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
WebContent/img/private.xcf
Normal file
BIN
WebContent/img/private.xcf
Normal file
Binary file not shown.
BIN
WebContent/img/user-share.png
Normal file
BIN
WebContent/img/user-share.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 881 B |
BIN
WebContent/img/user-silhouette.png
Normal file
BIN
WebContent/img/user-silhouette.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 511 B |
|
|
@ -260,7 +260,7 @@ public class Zallery extends HttpServlet{
|
||||||
if(request.getParameter("folder") != null && !request.getParameter("folder").equalsIgnoreCase("null"))
|
if(request.getParameter("folder") != null && !request.getParameter("folder").equalsIgnoreCase("null"))
|
||||||
folder = Folder.load(db, Long.parseLong(request.getParameter("folder")) );
|
folder = Folder.load(db, Long.parseLong(request.getParameter("folder")) );
|
||||||
else{
|
else{
|
||||||
folder = Folder.loadRoot(db);
|
folder = Folder.loadRoot(db, user);
|
||||||
// Setup new root folder
|
// Setup new root folder
|
||||||
if( folder == null ){
|
if( folder == null ){
|
||||||
folder = Folder.genRoot();
|
folder = Folder.genRoot();
|
||||||
|
|
@ -268,7 +268,7 @@ public class Zallery extends HttpServlet{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Media> list = Media.load(db, folder);
|
List<Media> list = Media.load(db, folder);
|
||||||
List<Folder> subFolders = Folder.loadSubFolders(db, folder.getId());
|
List<Folder> subFolders = Folder.loadSubFolders(db, folder.getId(), user);
|
||||||
|
|
||||||
//session.setAttribute("user", user);
|
//session.setAttribute("user", user);
|
||||||
request.setAttribute("folder", folder);
|
request.setAttribute("folder", folder);
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,18 @@ public class ZalleryAjax extends HttpServlet{
|
||||||
if( action.equalsIgnoreCase("verfemail") ){
|
if( action.equalsIgnoreCase("verfemail") ){
|
||||||
User verfuser = User.load(db, Long.parseLong(request.getParameter("id")));
|
User verfuser = User.load(db, Long.parseLong(request.getParameter("id")));
|
||||||
if( verfuser.verifyEmail(request.getParameter("hash")) ){
|
if( verfuser.verifyEmail(request.getParameter("hash")) ){
|
||||||
|
if( verfuser.isEnabled() )
|
||||||
|
if(out != null) out.println("{ }");
|
||||||
|
else msgs.add(MessageType.INFO, "Your email has been successfully verified");
|
||||||
|
else {
|
||||||
sendEmailNewUserToAdmin(verfuser, db);
|
sendEmailNewUserToAdmin(verfuser, db);
|
||||||
verfuser.save(db);
|
|
||||||
if(out != null) out.println("{ }");
|
if(out != null) out.println("{ }");
|
||||||
else msgs.add(MessageType.INFO, "Your email has been successfully verified, the account is waiting account activation by an admin.");
|
else msgs.add(MessageType.INFO, "Your email has been successfully verified, the account is waiting account activation by an admin.");
|
||||||
}
|
}
|
||||||
else if(out != null) out.println("{ \"error\":\"Email verification failed!\" }");
|
verfuser.save(db);
|
||||||
else msgs.add(MessageType.ERROR, "Email verification failed!");
|
}
|
||||||
|
else if(out != null) out.println("{ \"error\":\"Invalid email verification hash!\" }");
|
||||||
|
else msgs.add(MessageType.ERROR, "Invalid email verification hash!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,6 +306,33 @@ public class ZalleryAjax extends HttpServlet{
|
||||||
else if(out != null) out.println("{ \"error\": \"No such item!\"}");
|
else if(out != null) out.println("{ \"error\": \"No such item!\"}");
|
||||||
else msgs.add(MessageType.ERROR, "The item does not exist!");
|
else msgs.add(MessageType.ERROR, "The item does not exist!");
|
||||||
|
|
||||||
|
}
|
||||||
|
// Toggle folder private
|
||||||
|
else if( action.equalsIgnoreCase("mkprivate") ){
|
||||||
|
if( request.getParameter("id") == null){
|
||||||
|
if(out != null) out.println("{ \"error\": \"Missing parameters!\"}");
|
||||||
|
else msgs.add(MessageType.ERROR, "Missing parameters!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long id = Long.parseLong(request.getParameter("id"));
|
||||||
|
Folder folder = Folder.load(db, id);
|
||||||
|
|
||||||
|
if( folder != null ){
|
||||||
|
if( user.canEdit(folder) ){
|
||||||
|
folder.setPrivate( !folder.isPrivate() );
|
||||||
|
folder.save(db);
|
||||||
|
if(out != null) out.println("{}");
|
||||||
|
else{
|
||||||
|
if(folder.isPrivate()) msgs.add(MessageType.INFO, "Folder is now private (not visible to other users).");
|
||||||
|
else msgs.add(MessageType.INFO, "Folder is now public (can be viewed by other users).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(out != null) out.println("{ \"error\": \"You are not authorize to edit this folder!\"}");
|
||||||
|
else msgs.add(MessageType.ERROR, "You are not authorize to edit this folder!");
|
||||||
|
}
|
||||||
|
else if(out != null) out.println("{ \"error\": \"No such folder!\"}");
|
||||||
|
else msgs.add(MessageType.ERROR, "The folder does not exist!");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( action.equalsIgnoreCase("rmdir") ){
|
else if( action.equalsIgnoreCase("rmdir") ){
|
||||||
if( request.getParameter("id") == null){
|
if( request.getParameter("id") == null){
|
||||||
|
|
@ -336,7 +368,7 @@ public class ZalleryAjax extends HttpServlet{
|
||||||
// parent folder
|
// parent folder
|
||||||
if( folder == null ){
|
if( folder == null ){
|
||||||
String[] dirs = path.split("/");
|
String[] dirs = path.split("/");
|
||||||
Folder parent = Folder.loadRoot(db);
|
Folder parent = Folder.loadRoot(db, user);
|
||||||
if( user.isSuperUser() && path.charAt(0) == '/' )
|
if( user.isSuperUser() && path.charAt(0) == '/' )
|
||||||
path = "";
|
path = "";
|
||||||
else{
|
else{
|
||||||
|
|
@ -345,7 +377,7 @@ public class ZalleryAjax extends HttpServlet{
|
||||||
// Get root folder
|
// Get root folder
|
||||||
parent = Folder.load(db, path, user); // Get user root folder
|
parent = Folder.load(db, path, user); // Get user root folder
|
||||||
if( parent == null ){ // Create root folder
|
if( parent == null ){ // Create root folder
|
||||||
parent = Folder.loadRoot(db); // get root folder
|
parent = Folder.loadRoot(db, user); // get root folder
|
||||||
folder = new Folder();
|
folder = new Folder();
|
||||||
folder.setUser( user );
|
folder.setUser( user );
|
||||||
folder.setParent( parent );
|
folder.setParent( parent );
|
||||||
|
|
@ -409,7 +441,7 @@ public class ZalleryAjax extends HttpServlet{
|
||||||
smtpEmail.setSubject("Registration at "+Zallery.getWebsiteName());
|
smtpEmail.setSubject("Registration at "+Zallery.getWebsiteName());
|
||||||
smtpEmail.setContentType(ContentType.HTML);
|
smtpEmail.setContentType(ContentType.HTML);
|
||||||
smtpEmail.setMessage("You receive this message because you have requested an account" +
|
smtpEmail.setMessage("You receive this message because you have requested an account" +
|
||||||
"<br>at <a href='"+Zallery.getWebsiteURL()+"'>"+Zallery.getWebsiteName()+"</a>. Please click the link to verify your email address: " +
|
"<br>at "+Zallery.getWebsiteName()+". Please click the link to verify your email address: " +
|
||||||
"<p><a href='"+Zallery.getWebsiteURL()+"?action=verfemail&id="+user.getId()+"&hash="+user.getEmailVerificationHash()+"'>"+Zallery.getWebsiteURL()+"?action=verfemail&id="+user.getId()+"&hash="+user.getEmailVerificationHash()+"</a>" +
|
"<p><a href='"+Zallery.getWebsiteURL()+"?action=verfemail&id="+user.getId()+"&hash="+user.getEmailVerificationHash()+"'>"+Zallery.getWebsiteURL()+"?action=verfemail&id="+user.getId()+"&hash="+user.getEmailVerificationHash()+"</a>" +
|
||||||
"<p> You will have to wait for an admin to activate your account after you have verified your email.");
|
"<p> You will have to wait for an admin to activate your account after you have verified your email.");
|
||||||
smtpEmail.send();
|
smtpEmail.send();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ public class Folder extends DBBean{
|
||||||
protected String path;
|
protected String path;
|
||||||
protected Folder parent;
|
protected Folder parent;
|
||||||
protected Timestamp date;
|
protected Timestamp date;
|
||||||
|
protected boolean isPrivate;
|
||||||
|
|
||||||
//@DBLinkTable(name="FolderTree", beanClass=Folder.class, idColumn="parent")
|
//@DBLinkTable(name="FolderTree", beanClass=Folder.class, idColumn="parent")
|
||||||
//protected LinkedList<Folder> subFolders;
|
//protected LinkedList<Folder> subFolders;
|
||||||
|
|
@ -34,15 +35,17 @@ public class Folder extends DBBean{
|
||||||
public static Folder load(DBConnection db, Long id) throws SQLException{
|
public static Folder load(DBConnection db, Long id) throws SQLException{
|
||||||
return load(db, Folder.class, id);
|
return load(db, Folder.class, id);
|
||||||
}
|
}
|
||||||
public static List<Folder> loadSubFolders(DBConnection db, Long id) throws SQLException{
|
public static List<Folder> loadSubFolders(DBConnection db, Long id, User user) throws SQLException{
|
||||||
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE parent=?");
|
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE parent=? AND (isPrivate=0 OR user=?)");
|
||||||
sql.setLong(1, id);
|
sql.setLong(1, id);
|
||||||
|
sql.setLong(2, user.getId());
|
||||||
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Folder loadRoot(DBConnection db) throws SQLException{
|
public static Folder loadRoot(DBConnection db, User user) throws SQLException{
|
||||||
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE path=?");
|
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE path=? AND (isPrivate=0 OR user=?)");
|
||||||
sql.setString(1, "/");
|
sql.setString(1, "/");
|
||||||
|
sql.setLong(2, user.getId());
|
||||||
return DBConnection.exec(sql, DBBeanSQLResultHandler.create(Folder.class, db));
|
return DBConnection.exec(sql, DBBeanSQLResultHandler.create(Folder.class, db));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,6 +88,12 @@ public class Folder extends DBBean{
|
||||||
public void setUser(User user){
|
public void setUser(User user){
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
public boolean isPrivate(){
|
||||||
|
return isPrivate;
|
||||||
|
}
|
||||||
|
public void setPrivate(boolean priv){
|
||||||
|
this.isPrivate = priv;
|
||||||
|
}
|
||||||
public String getPath(){
|
public String getPath(){
|
||||||
String tmp = path.replaceAll("\\{NAME\\}", user.getName());
|
String tmp = path.replaceAll("\\{NAME\\}", user.getName());
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
@ -180,6 +189,6 @@ public class Folder extends DBBean{
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty(DBConnection db) throws SQLException {
|
public boolean isEmpty(DBConnection db) throws SQLException {
|
||||||
return Folder.loadSubFolders(db, this.getId()).isEmpty() && Media.load(db, this).isEmpty();
|
return Folder.loadSubFolders(db, this.getId(), user).isEmpty() && Media.load(db, this).isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue