summaryrefslogtreecommitdiff
path: root/utils/modules
diff options
context:
space:
mode:
authordeva <deva>2010-02-28 13:06:39 +0000
committerdeva <deva>2010-02-28 13:06:39 +0000
commit9cff69d330760c133d2b22c96da7a89e319b2362 (patch)
tree2fcaf78432ed03a092b1b57e9155c0c294c03eab /utils/modules
parent5b272cd81712a01fceb946682bb99f8402c070df (diff)
Better control of xml enconding... still a lot of testing to do though.
Diffstat (limited to 'utils/modules')
-rw-r--r--utils/modules/events.php9
-rw-r--r--utils/modules/news.php13
-rw-r--r--utils/modules/newsletter.php28
-rw-r--r--utils/modules/pressrelease.php155
4 files changed, 167 insertions, 38 deletions
diff --git a/utils/modules/events.php b/utils/modules/events.php
index cf04734..6e1218f 100644
--- a/utils/modules/events.php
+++ b/utils/modules/events.php
@@ -15,11 +15,10 @@ class Event {
public function write($fp)
{
- fwrite($fp, " <event title=\"" .
- htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n");
- fwrite($fp, " time=\"" . $this->time . "\"\n");
- fwrite($fp, " flyer=\"" . $this->flyer . "\">");
- fwrite($fp, htmlspecialchars($this->description, ENT_QUOTES, "UTF-8"));
+ fwrite($fp, " <event title=\"" .xmlenc($this->title) . "\"\n");
+ fwrite($fp, " time=\"" . xmlenc($this->time) . "\"\n");
+ fwrite($fp, " flyer=\"" . xmlenc($this->flyer) . "\">");
+ fwrite($fp, xmlenc($this->description));
fwrite($fp, " </event>\n");
}
diff --git a/utils/modules/news.php b/utils/modules/news.php
index 29187ea..00f1d4c 100644
--- a/utils/modules/news.php
+++ b/utils/modules/news.php
@@ -50,13 +50,12 @@ class NewsEntry {
public function write($fp)
{
- fwrite($fp, " <newsentry title=\"" .
- htmlspecialchars($this->title, ENT_QUOTES, "UTF-8") . "\"\n");
- fwrite($fp, " time=\"" . $this->time . "\"\n");
- fwrite($fp, " category=\"" . $this->category . "\"\n");
- fwrite($fp, " userid=\"" . $this->userid . "\"\n");
- fwrite($fp, " icon=\"" . $this->icon . "\">");
- fwrite($fp, htmlspecialchars($this->description, ENT_QUOTES, "UTF-8"));
+ fwrite($fp, " <newsentry title=\"".xmlenc($this->title)."\"\n");
+ fwrite($fp, " time=\"" . xmlenc($this->time) . "\"\n");
+ fwrite($fp, " category=\"" . xmlenc($this->category) . "\"\n");
+ fwrite($fp, " userid=\"" . xmlenc($this->userid) . "\"\n");
+ fwrite($fp, " icon=\"" . xmlenc($this->icon) . "\">");
+ fwrite($fp, xmlenc($this->description));
fwrite($fp, " </newsentry>\n");
}
diff --git a/utils/modules/newsletter.php b/utils/modules/newsletter.php
index 4bba9c6..3ca3f41 100644
--- a/utils/modules/newsletter.php
+++ b/utils/modules/newsletter.php
@@ -3,6 +3,7 @@
global $UTIL_DIR;
include_once($UTIL_DIR . "/mail.php");
+include_once($UTIL_DIR . "/convert.php");
class Mailinglist extends _Mailinglist {
private $file;
@@ -13,15 +14,14 @@ class Mailinglist extends _Mailinglist {
$fp = fopen($this->file, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fwrite($fp, "<mailinglist subj_prefix=\"" . $this->subj_prefix . "\"\n");
- fwrite($fp, " sender=\"" . $this->sender . "\"\n");
- fwrite($fp, " replyto=\"" . $this->replyto . "\"\n");
- fwrite($fp, " unsubscribe_url=\"" . $this->unsubscribe_url . "\">\n");
- fwrite($fp, " <footer>" . $this->footer . "</footer>\n");
+ fwrite($fp, "<mailinglist subj_prefix=\"" . xmlenc($this->subj_prefix) . "\"\n");
+ fwrite($fp, " sender=\"" . xmlenc($this->sender) . "\"\n");
+ fwrite($fp, " replyto=\"" . xmlenc($this->replyto) . "\"\n");
+ fwrite($fp, " unsubscribe_url=\"" . xmlenc($this->unsubscribe_url) . "\">\n");
+ fwrite($fp, " <footer>" . xmlenc($this->footer) . "</footer>\n");
foreach($this->mailinglist as $email) {
- fwrite($fp, " <email email=\"" .
- htmlspecialchars($email->email, ENT_QUOTES, "UTF-8") . "\"\n");
- fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n");
+ fwrite($fp, " <email email=\"" . xmlenc($email->email) . "\"\n");
+ fwrite($fp, " timestamp=\"" . xmlenc($email->timestamp) . "\">\n");
fwrite($fp, " </email>\n");
}
fwrite($fp, "</mailinglist>\n");
@@ -64,9 +64,11 @@ class Mailinglist extends _Mailinglist {
$email = new EMail($emailaddr, time());
if($this->add($email)) {
$this->write();
- $str .= "<div class=\"newsletter_message\">The email: " . $emailaddr . " has now been subscribed.</div>";
+ $str .= "<div class=\"newsletter_message\">The email: " .
+ $emailaddr . " has now been subscribed.</div>";
} else {
- $str .= "<div class=\"newsletter_message\">The email: " . $emailaddr . " is already subscribed.</div>";
+ $str .= "<div class=\"newsletter_message\">The email: " .
+ $emailaddr . " is already subscribed.</div>";
}
return $str;
}
@@ -76,9 +78,11 @@ class Mailinglist extends _Mailinglist {
$str = "";
if($this->remove($emailaddr)) {
$this->write();
- $str .= "<div class=\"newsletter_message\">The email: " . $emailaddr . " has now been unsubscribed.</div>";
+ $str .= "<div class=\"newsletter_message\">The email: " .
+ $emailaddr . " has now been unsubscribed.</div>";
} else {
- $str .= "<div class=\"newsletter_message\">The email: " . $emailaddr . " is not subscribed.</div>";
+ $str .= "<div class=\"newsletter_message\">The email: " .
+ $emailaddr . " is not subscribed.</div>";
}
return $str;
}
diff --git a/utils/modules/pressrelease.php b/utils/modules/pressrelease.php
index 4779ffa..542edd0 100644
--- a/utils/modules/pressrelease.php
+++ b/utils/modules/pressrelease.php
@@ -3,10 +3,11 @@
global $UTIL_DIR;
include_once($UTIL_DIR . "/mail.php");
+include_once($UTIL_DIR . "/convert.php");
class PEmail extends Email {
public $url;
- public $title;
+ public $name;
};
class PMailinglist extends _Mailinglist {
@@ -17,15 +18,14 @@ class PMailinglist extends _Mailinglist {
$fp = fopen($this->file, "w");
fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fwrite($fp, "<pressrelease subj_prefix=\"" . $this->subj_prefix . "\"\n");
- fwrite($fp, " sender=\"" . $this->sender . "\"\n");
- fwrite($fp, " replyto=\"" . $this->replyto . "\">\n");
- fwrite($fp, " <footer>" . $this->footer . "</footer>\n");
+ fwrite($fp, "<pressrelease subj_prefix=\"" . xmlenc($this->subj_prefix) . "\"\n");
+ fwrite($fp, " sender=\"" . xmlenc($this->sender) . "\"\n");
+ fwrite($fp, " replyto=\"" . xmlenc($this->replyto) . "\">\n");
+ fwrite($fp, " <footer>" . xmlenc($this->footer) . "</footer>\n");
foreach($this->mailinglist as $email) {
- fwrite($fp, " <email email=\"" .
- htmlspecialchars($email->email, ENT_QUOTES, "UTF-8") . "\"\n");
- fwrite($fp, " url=\"" . $email->url . "\">\n");
- fwrite($fp, " name=\"" . $email->name . "\">\n");
+ fwrite($fp, " <email email=\"" . xmlenc($email->email) . "\"\n");
+ fwrite($fp, " url=\"" . xmlenc($email->url) . "\"\n");
+ fwrite($fp, " name=\"" . xmlenc($email->name) . "\">\n");
fwrite($fp, " </email>\n");
}
fwrite($fp, "</pressrelease>\n");
@@ -77,7 +77,11 @@ class PressRelease {
// Admin config
public $admin_title = "Press release";
public $admin_submodules = array("Send" => "send",
- "Config" => "config");
+ "Config" => "config",
+ "Add receiver" => "add",
+ "Edit receiver" => "edit",
+ "Delete receiver" => "delete",
+ "View receivers" => "view");
public function admin_send($action, $vars)
{
@@ -133,16 +137,123 @@ class PressRelease {
default:
$form = new Form("update");
- $form->addWidget(new LineEdit("Subject prefix:", "subj_prefix", $this->mailinglist->subj_prefix));
- $form->addWidget(new LineEdit("Sender:", "sender", $this->mailinglist->sender));
- $form->addWidget(new LineEdit("Reply to:", "replyto", $this->mailinglist->replyto));
- $form->addWidget(new TextEdit("Footer:", "footer", $this->mailinglist->footer));
+ $form->addWidget(new LineEdit("Subject prefix:", "subj_prefix",
+ $this->mailinglist->subj_prefix));
+ $form->addWidget(new LineEdit("Sender:", "sender",
+ $this->mailinglist->sender));
+ $form->addWidget(new LineEdit("Reply to:", "replyto",
+ $this->mailinglist->replyto));
+ $form->addWidget(new TextEdit("Footer:", "footer",
+ $this->mailinglist->footer));
$form->addWidget(new Button("Update"));
$form->render();
break;
}
}
+ public function admin_add($action, $vars)
+ {
+ global $UID, $GLOBALS;
+
+ switch($action) {
+ case "add":
+ $pemail = new PEmail($vars["email"], time());
+ $pemail->url = $vars["url"];
+ $pemail->name = $vars["name"];
+ $this->mailinglist->add($pemail);
+ $this->mailinglist->write();
+ break;
+
+ default:
+ $form = new Form("add");
+ $form->addWidget(new LineEdit("Email:", "email", ""));
+ $form->addWidget(new LineEdit("URL:", "url", ""));
+ $form->addWidget(new LineEdit("Name:", "name", ""));
+ $form->addWidget(new Button("Add"));
+ $form->render();
+ break;
+ }
+ }
+
+ public function admin_edit($action, $vars)
+ {
+ switch($action) {
+ case "write":
+ $email = $this->mailinglist->mailinglist[$vars["editid"]];
+ $email->email = $vars["email"];
+ $email->url = $vars["url"];
+ $email->name = $vars["name"];
+ $this->mailinglist->write();
+ break;
+
+ case "edit":
+ $email = $this->mailinglist->mailinglist[$vars["editid"]];
+
+ $form = new Form("write");
+ $form->addWidget(new Hidden(array("editid" => $email->email)));
+ $form->addWidget(new LineEdit("Email:", "email", $email->email));
+ $form->addWidget(new LineEdit("URL:", "url", $email->url));
+ $form->addWidget(new LineEdit("Name:", "name", $email->name));
+ $form->addWidget(new Button("Edit"));
+ $form->render();
+ break;
+
+ default:
+ $rcvlist = array();
+ foreach($this->mailinglist->mailinglist as $m) {
+ $title = $m->name . " (".$m->email.")";
+ $rcvlist[$title] = $m->email;
+ }
+
+ ksort($rcvlist);
+
+ $form = new Form("edit");
+ $form->addWidget(new ComboBox("Select receiver to edit:", "editid", "", $rcvlist));
+ $form->addWidget(new Button("Edit..."));
+ $form->render();
+ break;
+ }
+ }
+
+ public function admin_delete($action, $vars)
+ {
+ switch($action) {
+ case "delete":
+ $this->mailinglist->remove($vars["delrcv"]);
+ $this->mailinglist->write();
+ break;
+
+ default:
+ $rcvlist = array();
+ foreach($this->mailinglist->mailinglist as $m) {
+ $title = $m->name . " (".$m->email.")";
+ $rcvlist[$title] = $m->email;
+ }
+
+ ksort($rcvlist);
+
+ $form = new Form("delete");
+ $form->addWidget(new ComboBox("Select receiver to delete:", "delrcv", "", $rcvlist));
+ $form->addWidget(new Button("Delete"));
+ $form->render();
+ break;
+ }
+ }
+
+ public function admin_view($action, $vars)
+ {
+ switch($action) {
+ default:
+ echo "<p>There are " . sizeof($this->mailinglist->mailinglist) . " receivers:</p>\n";
+ echo "<ul>\n";
+ foreach($this->mailinglist->mailinglist as $m) {
+ echo " <li>".xmlenc($m->name)." (<a href=\"".xmlenc($m->url)."\">".$m->url."</a>): ".xmlenc($m->email)."</li>\n";
+ }
+ echo "</ul>\n";
+ break;
+ }
+ }
+
public function admin($sub, $action, $vars)
{
switch($sub) {
@@ -153,6 +264,22 @@ class PressRelease {
case "config":
$this->admin_config($action, $vars);
break;
+
+ case "add":
+ $this->admin_add($action, $vars);
+ break;
+
+ case "edit":
+ $this->admin_edit($action, $vars);
+ break;
+
+ case "delete":
+ $this->admin_delete($action, $vars);
+ break;
+
+ case "view":
+ $this->admin_view($action, $vars);
+ break;
}
}