summaryrefslogtreecommitdiff
path: root/utils/modules/pressrelease.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/modules/pressrelease.php')
-rw-r--r--utils/modules/pressrelease.php155
1 files changed, 141 insertions, 14 deletions
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;
}
}