Changeset 276 for ether_megapoli
- Timestamp:
- 12/01/11 15:03:49 (12 years ago)
- Location:
- ether_megapoli/trunk/web
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/web/backoffice/user-script.jsp
r275 r276 54 54 url: "backoffice?methodName=addUser&" + parametersUrl, 55 55 success:jQuery.proxy( this.handleUser, this ), 56 error: function ( result ) 57 { 58 window.alert( 'Erreur de transmission au serveur' + result.responseText ); 59 } 56 error: jQuery.proxy( this.showErrors, [this] ) 60 57 } ); 61 58 } … … 80 77 url: "backoffice?methodName=modifyUser&" + parametersUrl, 81 78 success:jQuery.proxy( this.handleModifyUser, this ), 82 error: jQuery.proxy( function ( result ) 83 { 84 this.containerErrors.show(); 85 this.containerErrors.html( interfaceTexts[result.responseText] ); 86 }, this ) 87 } ); 88 } 79 error: jQuery.proxy( this.showErrors, [this] ) 80 } ); 81 } 82 }, 83 84 requestAcceptUser: function( waitingUser ) 85 { 86 if( waitingUser ) 87 $.ajax( { 88 url: "backoffice?methodName=acceptOrRefuseUser&id=" + waitingUser.id + "&ok=true", 89 success: jQuery.proxy( this.handleUser, this ), 90 error: jQuery.proxy( this.showErrors, [this, waitingUser.email ] ) 91 } ); 92 }, 93 94 requestRefuseUser: function( waitingUser ) 95 { 96 if( waitingUser ) 97 $.ajax( { 98 url: "backoffice?methodName=acceptOrRefuseUser&id=" + waitingUser.id + "&ok=false", 99 success: jQuery.proxy( this.handleUser, this ), 100 error: jQuery.proxy( this.showErrors, [this, waitingUser.email ] ) 101 } ); 89 102 }, 90 103 … … 138 151 this.containerWaitingUsers.empty(); 139 152 140 if( this.jsonWaitingUsers && this.jsonWaitingUsers.length > 0)153 if( this.jsonWaitingUsers && 0 < this.jsonWaitingUsers.length ) 141 154 { 142 155 jQuery.each( this.jsonWaitingUsers, jQuery.proxy( function( i, waitingUser ) … … 146 159 // Buttons 147 160 var tdAccept = $( document.createElement( "td" ) ); 148 var buttonAccept = new Button( {value:interfaceTexts["bo.accept"], parent:tdAccept, id:"button_accept", className: "small positive action_button", onClick:jQuery.proxy( this.onClickAccept, waitingUser)} );161 var buttonAccept = new Button( {value:interfaceTexts["bo.accept"], parent:tdAccept, id:"button_accept", className: "small positive action_button", contextToSave: waitingUser, onClick:jQuery.proxy( this.requestAcceptUser, this )} ); 149 162 tr.append( tdAccept ); 150 163 151 164 var tdRefuse = $( document.createElement( "td" ) ); 152 var buttonRefuse = new Button( {value:interfaceTexts["bo.refuse"], parent:tdRefuse, id:"button_refuse", className: "small negative action_button", onClick:jQuery.proxy( this.onClickRefuse, waitingUser)} );165 var buttonRefuse = new Button( {value:interfaceTexts["bo.refuse"], parent:tdRefuse, id:"button_refuse", className: "small negative action_button", contextToSave: waitingUser, onClick:jQuery.proxy( this.requestRefuseUser, this )} ); 153 166 tr.append( tdRefuse ); 154 167 … … 322 335 } 323 336 return errors; 337 }, 338 339 showErrors: function( result ) 340 { 341 var context = this[0]; 342 var text = this[1]; 343 context.containerErrors.show(); 344 if( text ) 345 context.containerErrors.html( interfaceTexts[result.responseText] + " " + text ); 346 else 347 context.containerErrors.html( interfaceTexts[result.responseText] ); 324 348 } 325 349 -
ether_megapoli/trunk/web/src/com/ether/ControllerBackoffice.java
r275 r276 6 6 import com.ether.user.UserRole; 7 7 import com.ether.user.UserState; 8 import com.medias.mail.Mail; 9 import com.medias.mail.MailFactory; 8 10 import net.sf.json.JSONObject; 9 11 import org.apache.commons.logging.Log; … … 79 81 } 80 82 else 81 throw new WebException( WebException.WebCode.USER_ALREADY_EXISTS, "This email already corresponds to an User" );83 throw new WebException( WebException.WebCode.USER_ALREADY_EXISTS, "This email already corresponds to an User", WebException.getBoThrowable() ); 82 84 83 85 return getAllAndWaitingUsers(); … … 124 126 } 125 127 128 @ControllerMethod(jsonResult = true) 129 public JSONObject acceptOrRefuseUser( @NotNull @ParamName(ParameterConstants.PARAMETER_ID) final Integer userId, 130 @ParamName(ParameterConstants.PARAMETER_OK) final boolean isAccepted ) 131 throws WebException, ServiceException 132 { 133 _etherService.acceptOrRefuseUser( userId, isAccepted ); 134 135 // Send email to the user 136 final User user = _etherService.getUserById( userId ); 137 final MailFactory mailFactory = (MailFactory) getServletContext().getAttribute( "APP_MAILFACTORY" ); 138 final String from = (String) getServletContext().getAttribute( "APP_WEBMASTER" ); 139 final String to = user.getEmail(); 140 final String subject = "[MEGAPOLI] User"; 141 final Mail mail = new Mail( from, to, null, "", subject ); 142 try 143 { 144 mailFactory.sendMail( mail ); 145 } 146 catch( Exception e ) 147 { 148 throw new WebException( WebException.WebCode.ERROR_EMAIL_CANNOT_BE_SEND, "The email cannot be send to the user : " + user.getEmail(), WebException.getBoThrowable() ); 149 } 150 151 return getAllAndWaitingUsers(); 152 } 153 154 126 155 private JSONObject getAllAndWaitingUsers() 127 156 throws ServiceException
Note: See TracChangeset
for help on using the changeset viewer.