import org.cacert.gigi.pages.orga.CreateOrgPage;
import org.cacert.gigi.pages.orga.ViewOrgPage;
import org.cacert.gigi.pages.wot.AssurePage;
-import org.cacert.gigi.pages.wot.MyListingPage;
import org.cacert.gigi.pages.wot.MyPoints;
import org.cacert.gigi.pages.wot.RequestTTPPage;
import org.cacert.gigi.ping.PingerDaemon;
putPage(AssurePage.PATH + "/*", new AssurePage(), "Web of Trust");
putPage(MyPoints.PATH, new MyPoints(), "Web of Trust");
- putPage(MyListingPage.PATH, new MyListingPage(), "Web of Trust");
putPage(RequestTTPPage.PATH, new RequestTTPPage(), "Web of Trust");
putPage(TTPAdminPage.PATH + "/*", new TTPAdminPage(), "Admin");
}
- public static final int CURRENT_SCHEMA_VERSION = 17;
+ public static final int CURRENT_SCHEMA_VERSION = 18;
public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
"suffix" varchar(50) NOT NULL DEFAULT '',
"dob" date NOT NULL,
"verified" boolean NOT NULL DEFAULT 'false',
- "ccid" int NOT NULL DEFAULT '0',
- "regid" int NOT NULL DEFAULT '0',
- "locid" int NOT NULL DEFAULT '0',
- "listme" boolean NOT NULL DEFAULT 'false',
- "contactinfo" varchar(255) NOT NULL DEFAULT '',
"language" varchar(5) NOT NULL DEFAULT '',
PRIMARY KEY ("id")
);
-CREATE INDEX ON "users" ("ccid");
-CREATE INDEX ON "users" ("regid");
-CREATE INDEX ON "users" ("locid");
CREATE INDEX ON "users" ("email");
CREATE INDEX ON "users" ("verified");
"version" smallint NOT NULL,
PRIMARY KEY ("version")
);
-INSERT INTO "schemeVersion" (version) VALUES(17);
+INSERT INTO "schemeVersion" (version) VALUES(18);
DROP TABLE IF EXISTS `passwordResetTickets`;
CREATE TABLE `passwordResetTickets` (
--- /dev/null
+ALTER TABLE "users" DROP "listme";
+ALTER TABLE "users" DROP "contactinfo";
+
+ALTER TABLE "users" DROP "ccid";
+ALTER TABLE "users" DROP "regid";
+ALTER TABLE "users" DROP "locid";
}
- public boolean wantsDirectoryListing() {
- try (GigiPreparedStatement get = new GigiPreparedStatement("SELECT listme FROM users WHERE id=?")) {
- get.setInt(1, getId());
- GigiResultSet exec = get.executeQuery();
- return exec.next() && exec.getBoolean("listme");
- }
- }
-
- public String getContactInformation() {
- try (GigiPreparedStatement get = new GigiPreparedStatement("SELECT contactinfo FROM users WHERE id=?")) {
- get.setInt(1, getId());
-
- GigiResultSet exec = get.executeQuery();
- exec.next();
- return exec.getString("contactinfo");
- }
- }
-
- public void setDirectoryListing(boolean on) {
- try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET listme = ? WHERE id = ?")) {
- update.setBoolean(1, on);
- update.setInt(2, getId());
- update.executeUpdate();
- }
- }
-
- public void setContactInformation(String contactInfo) {
- try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET contactinfo = ? WHERE id = ?")) {
- update.setString(1, contactInfo);
- update.setInt(2, getId());
- update.executeUpdate();
- }
- }
-
public boolean isInGroup(Group g) {
return groups.contains(g);
}
+++ /dev/null
-package org.cacert.gigi.pages.wot;
-
-import java.io.PrintWriter;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.cacert.gigi.dbObjects.User;
-import org.cacert.gigi.localisation.Language;
-import org.cacert.gigi.output.template.Form;
-import org.cacert.gigi.output.template.Template;
-
-public class MyListingForm extends Form {
-
- private static Template template;
-
- static {
- template = new Template(MyListingForm.class.getResource("MyListingForm.templ"));
- }
-
- private User target;
-
- public MyListingForm(HttpServletRequest hsr, User target) {
- super(hsr);
- this.target = target;
- }
-
- @Override
- public boolean submit(PrintWriter out, HttpServletRequest req) {
- if (req.getParameter("listme") != null && req.getParameter("contactinfo") != null) {
- boolean on = !req.getParameter("listme").equals("0");
- target.setDirectoryListing(on);
- if (on) {
- target.setContactInformation(req.getParameter("contactinfo"));
- } else {
- target.setContactInformation("");
- }
- return true;
- }
- return false;
- }
-
- @Override
- protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
- if (target.wantsDirectoryListing()) {
- vars.put("selected", "selected");
- vars.put("notSelected", "");
- vars.put("activeInfo", target.getContactInformation());
- } else {
- vars.put("selected", "");
- vars.put("notSelected", "selected");
- vars.put("activeInfo", target.getContactInformation());
- }
- template.output(out, l, vars);
- }
-
-}
+++ /dev/null
-<table class="table">
- <tr>
- <th colspan="2"><?=_My Listing?></td>
- </tr>
- <tr>
- <td><?=_Directory Listing?>:</td>
- <td>
- <select name="listme">
- <option value="0" <?=$notSelected?>><?=_I don't want to be listed?></option>
- <option value="1" <?=$selected?>><?=_I want to be listed?></option>
- </select>
- </td>
- </tr>
- <tr>
- <td><?=_Contact information?>:</td>
- <td><textarea class="form-control" name="contactinfo" cols="40" rows="5" wrap="virtual"><?=$activeInfo?></textarea></td>
- </tr>
- <tr>
- <td colspan="2"><input type="submit" name="processContact" value="<?=_Update?>"></td>
- </tr>
-</table>
\ No newline at end of file
+++ /dev/null
-package org.cacert.gigi.pages.wot;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.cacert.gigi.dbObjects.User;
-import org.cacert.gigi.output.template.Form;
-import org.cacert.gigi.pages.Page;
-import org.cacert.gigi.util.AuthorizationContext;
-
-public class MyListingPage extends Page {
-
- public static final String PATH = "/wot/listing";
-
- public MyListingPage() {
- super("My Listing");
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
- if (Form.getForm(req, MyListingForm.class).submit(resp.getWriter(), req)) {
- resp.sendRedirect(PATH);
- return;
- }
- super.doPost(req, resp);
- }
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
- new MyListingForm(req, getUser(req)).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
- }
-
- @Override
- public boolean isPermitted(AuthorizationContext ac) {
- return ac != null && ac.getTarget() instanceof User;
- }
-
-}
+++ /dev/null
-package org.cacert.gigi.pages.wot;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-
-import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.testUtils.ClientTest;
-import org.cacert.gigi.testUtils.IOUtils;
-import org.junit.Test;
-
-public class TestListing extends ClientTest {
-
- @Test
- public void testListing() throws IOException, GigiApiException {
- String c = IOUtils.readURL(get(MyListingPage.PATH));
- // Default settings not listed, empty text
- assertThat(c, not(containsString("value=\"1\" selected")));
- assertThat(c, containsString("value=\"0\" selected"));
- assertThat(c, containsString("></textarea>"));
-
- assertEquals(302, post(MyListingPage.PATH, "listme=0&contactinfo=a").getResponseCode());
- c = IOUtils.readURL(get(MyListingPage.PATH));
- assertThat(c, not(containsString("value=\"1\" selected")));
- assertThat(c, containsString("value=\"0\" selected"));
- assertThat(c, containsString("></textarea>"));
-
- assertEquals(302, post(MyListingPage.PATH, "listme=1&contactinfo=a").getResponseCode());
- c = IOUtils.readURL(get(MyListingPage.PATH));
- assertThat(c, containsString("value=\"1\" selected"));
- assertThat(c, not(containsString("value=\"0\" selected")));
- assertThat(c, containsString(">a</textarea>"));
-
- assertEquals(302, post(MyListingPage.PATH, "listme=1&contactinfo=b").getResponseCode());
- c = IOUtils.readURL(get(MyListingPage.PATH));
- assertThat(c, containsString("value=\"1\" selected"));
- assertThat(c, not(containsString("value=\"0\" selected")));
- assertThat(c, containsString(">b</textarea>"));
-
- assertEquals(302, post(MyListingPage.PATH, "listme=0&contactinfo=b").getResponseCode());
- c = IOUtils.readURL(get(MyListingPage.PATH));
- assertThat(c, containsString("value=\"0\" selected"));
- assertThat(c, not(containsString("value=\"1\" selected")));
- assertThat(c, containsString("></textarea>"));
- }
-}