Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PERFORMA_REPLICA
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Usman
PERFORMA_REPLICA
Commits
f6c97098
Commit
f6c97098
authored
Sep 12, 2017
by
chenith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grouped and Soered company users list and added option for resend email to pending user.
parent
f880576a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
72 deletions
+133
-72
SendUserInvitationFP.java
cmsWebApp/src/performa/form/SendUserInvitationFP.java
+57
-33
Utils.java
cmsWebApp/src/performa/utils/Utils.java
+21
-10
manage_users.jsp
cmsWebApp/webroot/extensions/adminportal/manage_users.jsp
+54
-29
messagesOverride.txt
...root/extensions/adminportal/messages/messagesOverride.txt
+1
-0
No files found.
cmsWebApp/src/performa/form/SendUserInvitationFP.java
View file @
f6c97098
...
@@ -15,7 +15,6 @@ import oneit.objstore.parser.BusinessObjectParser;
...
@@ -15,7 +15,6 @@ import oneit.objstore.parser.BusinessObjectParser;
import
oneit.security.SecUser
;
import
oneit.security.SecUser
;
import
oneit.servlets.forms.*
;
import
oneit.servlets.forms.*
;
import
oneit.servlets.process.*
;
import
oneit.servlets.process.*
;
import
oneit.servlets.utils.NotificationUtils
;
import
oneit.utils.*
;
import
oneit.utils.*
;
import
performa.orm.*
;
import
performa.orm.*
;
import
performa.utils.Utils
;
import
performa.utils.Utils
;
...
@@ -32,12 +31,20 @@ public class SendUserInvitationFP extends SaveFP
...
@@ -32,12 +31,20 @@ public class SendUserInvitationFP extends SaveFP
@Override
@Override
public
void
validate
(
ORMProcessState
process
,
SubmissionDetails
submission
,
MultiException
exceptions
,
Map
params
)
throws
StorageException
public
void
validate
(
ORMProcessState
process
,
SubmissionDetails
submission
,
MultiException
exceptions
,
Map
params
)
throws
StorageException
{
{
HttpServletRequest
request
=
submission
.
getRequest
();
HttpServletRequest
request
=
submission
.
getRequest
();
Company
company
=
(
Company
)
process
.
getAttribute
(
"Company"
);
Company
company
=
(
Company
)
process
.
getAttribute
(
"Company"
);
CompanyUser
resendUser
=
(
CompanyUser
)
request
.
getAttribute
(
"ResendUser"
);
BusinessObjectParser
.
assertFieldCondition
(
company
.
getUserEmail
()!=
null
,
company
,
Company
.
FIELD_UserEmail
,
"mandatory"
,
exceptions
,
true
,
request
);
if
(
resendUser
!=
null
)
BusinessObjectParser
.
assertFieldCondition
(!
isEmailFound
(
process
.
getTransaction
(),
company
.
getUserEmail
()),
company
,
Company
.
FIELD_UserEmail
,
"emailExists"
,
exceptions
,
true
,
request
);
{
BusinessObjectParser
.
assertFieldCondition
(
company
.
getRoleType
()!=
null
,
company
,
Company
.
FIELD_RoleType
,
"mandatory"
,
exceptions
,
true
,
request
);
BusinessObjectParser
.
assertFieldCondition
(
StringUtils
.
isEmailAddress
(
resendUser
.
getUser
().
getUserName
()),
resendUser
,
resendUser
.
FIELD_ObjectID
,
"invalidEmail"
,
exceptions
,
false
,
request
);
}
else
{
BusinessObjectParser
.
assertFieldCondition
(
company
.
getUserEmail
()!=
null
,
company
,
Company
.
FIELD_UserEmail
,
"mandatory"
,
exceptions
,
true
,
request
);
BusinessObjectParser
.
assertFieldCondition
(!
isEmailFound
(
process
.
getTransaction
(),
company
.
getUserEmail
()),
company
,
Company
.
FIELD_UserEmail
,
"emailExists"
,
exceptions
,
true
,
request
);
BusinessObjectParser
.
assertFieldCondition
(
company
.
getRoleType
()!=
null
,
company
,
Company
.
FIELD_RoleType
,
"mandatory"
,
exceptions
,
true
,
request
);
}
super
.
validate
(
process
,
submission
,
exceptions
,
params
);
super
.
validate
(
process
,
submission
,
exceptions
,
params
);
}
}
...
@@ -49,27 +56,39 @@ public class SendUserInvitationFP extends SaveFP
...
@@ -49,27 +56,39 @@ public class SendUserInvitationFP extends SaveFP
HttpServletRequest
request
=
submission
.
getRequest
();
HttpServletRequest
request
=
submission
.
getRequest
();
ObjectTransaction
objTran
=
process
.
getTransaction
();
ObjectTransaction
objTran
=
process
.
getTransaction
();
Company
company
=
(
Company
)
process
.
getAttribute
(
"Company"
);
Company
company
=
(
Company
)
process
.
getAttribute
(
"Company"
);
CompanyUser
resendUser
=
(
CompanyUser
)
request
.
getAttribute
(
"ResendUser"
);
if
(
resendUser
!=
null
)
{
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"Started to re-sending invitaion email."
,
resendUser
);
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"Started to create new use"
,
company
);
sendInvitationMail
(
resendUser
,
request
);
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"End of re-sending invitation email."
,
resendUser
);
}
else
{
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"Started to create new use"
,
company
);
SecUser
newUser
=
SecUser
.
createSecUser
(
objTran
);
SecUser
newUser
=
SecUser
.
createSecUser
(
objTran
);
CompanyUser
newComUser
=
newUser
.
getExtensionOrCreate
(
CompanyUser
.
REFERENCE_CompanyUser
);
CompanyUser
newComUser
=
newUser
.
getExtensionOrCreate
(
CompanyUser
.
REFERENCE_CompanyUser
);
newUser
.
setUserName
(
company
.
getUserEmail
().
toLowerCase
());
newUser
.
setEmail
(
newUser
.
getUserName
());
newUser
.
setAttribute
(
"md5:"
+
SecUser
.
FIELD_Password
,
DEFAULT_PASSWORD
);
newUser
.
addRole
(
Utils
.
getRole
(
Utils
.
ROLE_CLIENT
,
objTran
));
newUser
.
setFirstName
(
company
.
getFirstName
());
newUser
.
setLastName
(
company
.
getLastName
());
newComUser
.
setCompany
(
company
);
newComUser
.
setRole
(
company
.
getRoleType
());
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"New user created :: "
,
newUser
);
newUser
.
setUserName
(
company
.
getUserEmail
().
toLowerCase
());
newUser
.
setEmail
(
newUser
.
getUserName
());
sendInvitationMail
(
newComUser
,
request
);
newUser
.
setAttribute
(
"md5:"
+
SecUser
.
FIELD_Password
,
DEFAULT_PASSWORD
);
newUser
.
addRole
(
Utils
.
getRole
(
Utils
.
ROLE_CLIENT
,
objTran
));
newUser
.
setFirstName
(
company
.
getFirstName
());
newUser
.
setLastName
(
company
.
getLastName
());
newComUser
.
setCompany
(
company
);
newComUser
.
setRole
(
company
.
getRoleType
());
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"End of sending invitation email."
,
newUser
);
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"New user created :: "
,
newUser
);
sendInvitationMail
(
newComUser
,
request
);
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"End of sending invitation email."
,
newUser
);
}
return
super
.
processForm
(
process
,
submission
,
params
);
return
super
.
processForm
(
process
,
submission
,
params
);
}
}
...
@@ -92,19 +111,24 @@ public class SendUserInvitationFP extends SaveFP
...
@@ -92,19 +111,24 @@ public class SendUserInvitationFP extends SaveFP
{
{
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"Sending invitation mail from SendUserInvitationFP to :: "
,
companyUser
);
LogMgr
.
log
(
LOG
,
LogLevel
.
PROCESSING1
,
"Sending invitation mail from SendUserInvitationFP to :: "
,
companyUser
);
Article
invitationArticle
=
WebUtils
.
getArticleByShortCut
(
companyUser
.
getTransaction
(),
WebUtils
.
COMPANY_ACCOUNT_VERIFICATION
);
Article
invitationArticle
=
WebUtils
.
getArticleByShortCut
(
companyUser
.
getTransaction
(),
WebUtils
.
COMPANY_ACCOUNT_VERIFICATION
);
RandomStringGen
random
=
new
RandomStringGen
();
//set invitation key and send mail time
//set invitation key and send mail time
companyUser
.
setVerificationKey
(
random
.
generateAlphaNum
(
6
));
if
(
companyUser
.
getVerificationKey
()==
null
)
{
RandomStringGen
random
=
new
RandomStringGen
();
companyUser
.
setVerificationKey
(
random
.
generateAlphaNum
(
6
));
}
companyUser
.
setVerificationMailSendDate
(
new
Date
());
companyUser
.
setVerificationMailSendDate
(
new
Date
());
String
link
=
LoopbackHTTP
.
getRemoteAccessURL
(
request
)
String
link
=
LoopbackHTTP
.
getRemoteAccessURL
(
request
)
+
invitationArticle
.
getLink
(
request
,
CollectionUtils
.
EMPTY_MAP
,
"/"
)
+
invitationArticle
.
getLink
(
request
,
CollectionUtils
.
EMPTY_MAP
,
"/"
)
+
"?id="
+
companyUser
.
getID
()
+
"?id="
+
companyUser
.
getID
()
+
"&key="
+
companyUser
.
getVerificationKey
();
+
"&key="
+
companyUser
.
getVerificationKey
();
Map
defaultParams
=
CollectionUtils
.
mapEntry
(
"link"
,
link
).
toMap
();
Map
defaultParams
=
CollectionUtils
.
mapEntry
(
"link"
,
link
).
toMap
();
ObjectTransform
transform
=
Utils
.
createCompoundTransform
(
defaultParams
,
companyUser
);
ObjectTransform
transform
=
Utils
.
createCompoundTransform
(
defaultParams
,
companyUser
);
Utils
.
sendMail
(
invitationEmailer
,
transform
,
new
String
[]{
companyUser
.
getUser
().
getUserName
()},
null
,
companyUser
);
Utils
.
sendMail
(
invitationEmailer
,
transform
,
new
String
[]{
companyUser
.
getUser
().
getUserName
()},
null
,
companyUser
);
...
...
cmsWebApp/src/performa/utils/Utils.java
View file @
f6c97098
...
@@ -185,26 +185,22 @@ public class Utils
...
@@ -185,26 +185,22 @@ public class Utils
}
}
public
static
List
<
CompanyUser
>
getUsersSorted
(
Set
<
CompanyUser
>
users
,
UserSortOption
userSortOption
)
public
static
Collection
<
CompanyUser
>
getUsersSorted
(
Collection
<
CompanyUser
>
users
,
UserSortOption
userSortOption
)
{
{
ObjectTransform
transform
=
Client
.
pipesClient
().
toObjectCreated
();
Comparator
comparator
=
new
UserComparator
();
Comparator
comparator
=
CollectionUtils
.
DEFAULT_COMPARATOR
;
if
(
userSortOption
==
UserSortOption
.
ALPHA_A_Z
)
if
(
userSortOption
==
UserSortOption
.
ALPHA_A_Z
)
{
{
transform
=
CompanyUser
.
pipesCompanyUser
().
toUser
().
toFirstName
();
comparator
=
new
UserComparator
();
comparator
=
CollectionUtils
.
CASE_INSENSITIVE_COMPARATOR
;
}
}
else
if
(
userSortOption
==
UserSortOption
.
ALPHA_Z_A
)
else
if
(
userSortOption
==
UserSortOption
.
ALPHA_Z_A
)
{
{
transform
=
CompanyUser
.
pipesCompanyUser
().
toUser
().
toFirstName
();
comparator
=
CollectionUtils
.
reverse
(
new
UserComparator
());
comparator
=
CollectionUtils
.
reverse
(
CollectionUtils
.
CASE_INSENSITIVE_COMPARATOR
);
}
}
return
ObjstoreUtils
.
sort
(
users
,
return
CollectionUtils
.
sort
(
users
,
comparator
);
new
ObjectTransform
[]{
transform
},
new
Comparator
[]{
comparator
});
}
}
public
static
class
ClientToOpenJobCountTransform
implements
ObjectTransform
<
Client
,
Integer
>
public
static
class
ClientToOpenJobCountTransform
implements
ObjectTransform
<
Client
,
Integer
>
...
@@ -359,3 +355,17 @@ public class Utils
...
@@ -359,3 +355,17 @@ public class Utils
.
search
(
transaction
);
.
search
(
transaction
);
}
}
}
}
class
UserComparator
implements
Comparator
<
CompanyUser
>
{
@Override
public
int
compare
(
CompanyUser
o1
,
CompanyUser
o2
)
{
String
o1Name
=
StringUtils
.
subBlanks
(
o1
.
getUser
().
getName
())!=
null
?
o1
.
getUser
().
getName
()
:
o1
.
getUser
().
getUserName
();
String
o2Name
=
StringUtils
.
subBlanks
(
o2
.
getUser
().
getName
())!=
null
?
o2
.
getUser
().
getName
()
:
o2
.
getUser
().
getUserName
();
return
o1Name
.
trim
().
compareTo
(
o2Name
.
trim
());
}
}
\ No newline at end of file
cmsWebApp/webroot/extensions/adminportal/manage_users.jsp
View file @
f6c97098
<%@ page extends="oneit.servlets.jsp.JSPInclude" %>
<%@ page extends="oneit.servlets.jsp.JSPInclude" %>
<%@ include file="/inc/stdimports50.jsp" %><%-- This is in cougar --%>
<%@ include file="/inc/stdimports50.jsp" %><%-- This is in cougar --%>
<%@ include file="/inc/stdcms.jsp" %><%-- This is in cougar --%>
<%@ include file="/inc/stdcms.jsp" %><%-- This is in cougar --%>
<%@ include file="/extensions/performa/inc/stdimports.jsp" %>
<%@ include file="/extensions/performa/inc/stdimports.jsp" %>
<%@ page import="oneit.utils.filter.CollectionFilter"%>
<oneit:dynIncluded>
<oneit:dynIncluded>
<%
<%
String currentPage = WebUtils.getArticleByShortCut(process.getTransaction(), WebUtils.MANAGE_USERS).getLink(request);
String currentPage = WebUtils.getArticleByShortCut(process.getTransaction(), WebUtils.MANAGE_USERS).getLink(request);
...
@@ -12,15 +14,24 @@
...
@@ -12,15 +14,24 @@
SecUser secUser = SecUser.getTXUser(objTran);
SecUser secUser = SecUser.getTXUser(objTran);
Company company = (Company) process.getAttribute("Company");
Company company = (Company) process.getAttribute("Company");
CompanyUser comUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
CompanyUser comUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
UserSortOption userSortOpt = (UserSortOption) process.getAttribute("UserSortOption");
Collection companyUsers = (Collection<CompanyUser>) process.getAttribute("CompanyUsers");
Collection pendingUsers = (Collection<CompanyUser>) process.getAttribute("PendingUsers");
if(company==null)
if(company==null)
{
{
company = comUser.getCompany();
company = comUser.getCompany();
process.setAttribute("Company", company);
process.setAttribute("Company", company);
}
}
UserSortOption userSortOpt = (UserSortOption) process.getAttribute("UserSortOption");
if(companyUsers == null || pendingUsers == null)
Set<CompanyUser> companyUsers = (Set<CompanyUser>) process.getAttribute("CompanyUsers");
{
companyUsers = CollectionFilter.filter(company.getUsersSet(), CompanyUser.SearchByAll().andIsAccountVerified(new EqualsFilter<>(Boolean.TRUE)));
pendingUsers = CollectionFilter.filter(company.getUsersSet(), CompanyUser.SearchByAll().andIsAccountVerified(new NotEqualsFilter<>(Boolean.TRUE)));
process.setAttribute("CompanyUsers", companyUsers);
process.setAttribute("PendingUsers", pendingUsers);
}
if( request.getParameter("UserSortOption") != null)
if( request.getParameter("UserSortOption") != null)
{
{
...
@@ -29,19 +40,13 @@
...
@@ -29,19 +40,13 @@
if(userSortOpt == null)
if(userSortOpt == null)
{
{
userSortOpt = UserSortOption.ALPHA_A_Z;
userSortOpt = UserSortOption.ALPHA_A_Z;
}
if(companyUsers == null)
{
companyUsers = company.getUsersSet();
process.setAttribute("CompanyUsers", companyUsers);
}
}
List<CompanyUser> sortedUsers = Utils.getUsersSorted(companyUsers, userSortOpt);
process.setAttribute("UserSortOption", userSortOpt);
process.setAttribute("UserSortOption", userSortOpt);
Collection<CompanyUser> sortedCompanyUsers = Utils.getUsersSorted(companyUsers, userSortOpt);
Collection<CompanyUser> sortedPendingUsers = Utils.getUsersSorted(pendingUsers, userSortOpt);
%>
%>
<script type="text/javascript">
<script type="text/javascript">
...
@@ -84,7 +89,7 @@
...
@@ -84,7 +89,7 @@
</div>
</div>
<div class="main-manage-userlist">
<div class="main-manage-userlist">
<%
<%
for(CompanyUser companyUser :
c
ompanyUsers)
for(CompanyUser companyUser :
sortedC
ompanyUsers)
{
{
SecUser user = companyUser.getUser();
SecUser user = companyUser.getUser();
%>
%>
...
@@ -122,21 +127,41 @@
...
@@ -122,21 +127,41 @@
</div>
</div>
</div>
</div>
-->
-->
<div class="user-list-row">
<%
<div class="m-user-left">
for(CompanyUser pendingUser : sortedPendingUsers)
<div class="m-user-icon"><img src="images/user-list-icon.png"></div>
{
<div class="m-user-info">
SecUser user = pendingUser.getUser();
<div class="m-user-name">Janis Stein</div>
String name = StringUtils.subBlanks(user.getName())!=null ? user.getName() : user.getUserName();
<div class="m-user-email">janisstein@gmail.com</div>
String resendTxt = "Re-send invitation to " + (StringUtils.subBlanks(user.getFirstName())!=null ? user.getFirstName() : StringUtils.subBlanks(user.getLastName())!=null ? user.getLastName() : user.getUserName());
%>
<div class="user-list-row" id="<%= pendingUser.getID() %>">
<div class="m-user-left">
<div class="m-user-icon"><img src="images/user-list-icon.png"></div>
<div class="m-user-info">
<div class="m-user-name">
<oneit:toString value="<%= name %>" mode="EscapeHTML" />
</div>
<div class="m-user-email">
<oneit:toString value="<%= user.getEmail() %>" mode="EscapeHTML" />
</div>
</div>
</div>
<div class="m-user-right invite-combo">
<select class="form-control" disabled="">
<option>Invitation sent</option>
</select>
</div>
<div class="resend-link">
<oneit:button value="<%= resendTxt %>" name="sendUserInvites" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
.mapEntry ("ResendUser", pendingUser)
.mapEntry(NotificationUtils.NOTIFICATION_MSG_PARAM, "invitationSent")
.toMap() %>" />
</div>
</div>
</div>
</div>
<div class="m-user-right invite-combo">
<%
<select class="form-control" disabled="">
}
<option>Invitation sent</option>
%>
</select>
</div>
<div class="resend-link"><a href="#">Re-send invitation to Janis</a></div>
</div>
</div>
</div>
</div>
</div>
<div class="manage-user-right">
<div class="manage-user-right">
...
@@ -153,7 +178,7 @@
...
@@ -153,7 +178,7 @@
</div>
</div>
<div class="form-group">
<div class="form-group">
<label><oneit:label GUIName="Last Name" /></label>
<label><oneit:label GUIName="Last Name" /></label>
<oneit:ormInput obj="<%= company %>" type="text" attributeName="
Fir
stName" cssClass="form-control"/>
<oneit:ormInput obj="<%= company %>" type="text" attributeName="
La
stName" cssClass="form-control"/>
</div>
</div>
<div class="form-group">
<div class="form-group">
<label><oneit:label GUIName="Role" /></label>
<label><oneit:label GUIName="Role" /></label>
...
...
cmsWebApp/webroot/extensions/adminportal/messages/messagesOverride.txt
View file @
f6c97098
...
@@ -4,3 +4,4 @@
...
@@ -4,3 +4,4 @@
#passwordNotMatch = The password does not match. Please try again.
#passwordNotMatch = The password does not match. Please try again.
#resetPasswordEmailSent = A password rest email has been sent to you. Please check your email.
#resetPasswordEmailSent = A password rest email has been sent to you. Please check your email.
#invitationSent = Your invitation has been successfully sent.
#invitationSent = Your invitation has been successfully sent.
#invalidEmail = Invalid email address.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment