return resu;
}
- public void update(String o, String c, String st, String l) {
+ public void update(String o, String c, String st, String l, String mail) {
for (Certificate cert : getCertificates(false)) {
if (cert.getStatus() == CertificateStatus.ISSUED) {
cert.revoke();
}
}
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("UPDATE organisations SET name=?, state=?, province=?, city=?");
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("UPDATE organisations SET name=?, state=?, province=?, city=?, contactEmail=?");
ps.setString(1, o);
ps.setString(2, c);
ps.setString(3, st);
ps.setString(4, l);
+ ps.setString(5, mail);
ps.execute();
+ email = mail;
name = o;
state = c;
province = st;
import org.cacert.gigi.output.template.IterableDataset;
import org.cacert.gigi.output.template.Template;
import org.cacert.gigi.pages.LoginPage;
+import org.cacert.gigi.pages.Page;
public class AffiliationForm extends Form {
User toRemove = User.getByEmail(req.getParameter("del"));
if (toRemove != null) {
o.removeAdmin(toRemove, LoginPage.getUser(req));
+ return true;
}
- }
- if (req.getParameter("do_affiliate") != null) {
+ } else if (req.getParameter("do_affiliate") != null) {
User byEmail = User.getByEmail(req.getParameter("email"));
if (byEmail != null) {
o.addAdmin(byEmail, LoginPage.getUser(req), req.getParameter("master") != null);
+ return true;
}
}
- return true;
+ out.println(Page.getLanguage(req).getTranslation("No action could have been carried out."));
+ return false;
}
@Override
@Override
public boolean next(Language l, Map<String, Object> vars) {
- if ( !iter.hasNext())
+ if ( !iter.hasNext()) {
return false;
+ }
Affiliation aff = iter.next();
vars.put("name", aff.getTarget().getName());
vars.put("master", aff.isMaster() ? l.getTranslation("master") : "");
<td></td>
<td><input type="text" name="email"></td>
<td><input type="checkbox" name="master" value="y"></td>
- <td><input type="submit" name="do_affiliate" value="<?=_Add?>"><input type='hidden' name='affiliate' value='y'></td>
+ <td><input type="submit" name="do_affiliate" value="<?=_Add?>"></td>
</tr>
</table>
l = req.getParameter("L");
email = req.getParameter("contact");
if (result != null) {
- result.update(o, c, st, l);
+ result.update(o, c, st, l, email);
return true;
}
Organisation ne = new Organisation(o, c, st, l, email, LoginPage.getUser(req));
vars.put("C", c);
vars.put("ST", st);
vars.put("L", this.l);
+ vars.put("email", email);
if (isEdit) {
vars.put("edit", true);
}
</tr>
<tr>
<td><?=_Contact Email?>:</td>
- <td><input type="text" name="contact" value="" maxlength="255" size="90"></td>
+ <td><input type="text" name="contact" value="<?=$email?>" maxlength="255" size="90"></td>
</tr>
<tr>
<td><?=_Town/Suburb?>:</td>
if ( !u.isInGroup(CreateOrgPage.ORG_ASSURER)) {
return;
}
- if (req.getParameter("affiliate") != null) {
+ if (req.getParameter("do_affiliate") != null || req.getParameter("del") != null) {
AffiliationForm form = Form.getForm(req, AffiliationForm.class);
- form.submit(resp.getWriter(), req);
- resp.sendRedirect(DEFAULT_PATH + "/" + form.getOrganisation().getId());
+ if (form.submit(resp.getWriter(), req)) {
+ resp.sendRedirect(DEFAULT_PATH + "/" + form.getOrganisation().getId());
+ }
} else {
Form.getForm(req, CreateOrgForm.class).submit(resp.getWriter(), req);
}
@Override
public boolean next(Language l, Map<String, Object> vars) {
- if (count >= orgas.length)
+ if (count >= orgas.length) {
return false;
+ }
Organisation org = orgas[count++];
vars.put("id", Integer.toString(org.getId()));
vars.put("name", org.getName());
@Test
public void testAdd() throws IOException {
- executeBasicWebInteraction(session, CreateOrgPage.DEFAULT_PATH, "O=name&contact=&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0);
+ executeBasicWebInteraction(session, CreateOrgPage.DEFAULT_PATH, "O=name&contact=mail&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0);
Organisation[] orgs = Organisation.getOrganisations(0, 30);
assertEquals(1, orgs.length);
+ assertEquals("mail", orgs[0].getContactEmail());
assertEquals("name", orgs[0].getName());
assertEquals("Köln", orgs[0].getCity());
assertEquals("ÜÖÄß", orgs[0].getProvince());
User u2 = User.getById(createVerifiedUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD));
- executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&affiliate=y&master=y", 1);
+ executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&do_affiliate=y&master=y", 1);
List<Affiliation> allAdmins = orgs[0].getAllAdmins();
assertEquals(1, allAdmins.size());
Affiliation affiliation = allAdmins.get(0);
assertSame(u2, affiliation.getTarget());
assertTrue(affiliation.isMaster());
- executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&affiliate=y", 1);
+ executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&do_affiliate=y", 1);
allAdmins = orgs[0].getAllAdmins();
assertEquals(2, allAdmins.size());
Affiliation affiliation2 = allAdmins.get(0);
assertSame(u.getId(), affiliation2.getTarget().getId());
assertFalse(affiliation2.isMaster());
- executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&email=&affiliate=y", 1);
+ executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1);
assertEquals(1, orgs[0].getAllAdmins().size());
- executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&email=&affiliate=y", 1);
+ executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1);
assertEquals(0, orgs[0].getAllAdmins().size());
executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "O=name1&contact=&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0);