scorify the PM extension
This commit is contained in:
parent
85c8875ffe
commit
cdde0e072c
@ -13,22 +13,21 @@ class ET implements Extension {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("system_info")) {
|
||||
if($event->user->is_admin()) {
|
||||
$this->theme->display_info_page($event->page, $this->get_info());
|
||||
if($event->context->user->is_admin()) {
|
||||
$this->theme->display_info_page($event->page, $this->get_info($event->context));
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof UserBlockBuildingEvent) {
|
||||
if($event->user->is_admin()) {
|
||||
if($event->context->user->is_admin()) {
|
||||
$event->add_link("System Info", make_link("system_info"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// do it {{{
|
||||
private function get_info() {
|
||||
global $database;
|
||||
global $config;
|
||||
private function get_info($context) {
|
||||
$database = $context->database;
|
||||
$config = $context->config;
|
||||
global $_event_listeners; // yay for using secret globals \o/
|
||||
|
||||
$info = array();
|
||||
|
@ -6,11 +6,11 @@ class ETTheme extends Themelet {
|
||||
*
|
||||
* $info = an array of ($name => $value)
|
||||
*/
|
||||
public function display_info_page($page, $info) {
|
||||
public function display_info_page(Page $page, $info) {
|
||||
$page->set_title("System Info");
|
||||
$page->set_heading("System Info");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Data which is to be sent:", $this->build_data_form($info)));
|
||||
$page->add_block(new Block("Information:", $this->build_data_form($info)));
|
||||
}
|
||||
|
||||
protected function build_data_form($info) {
|
||||
@ -44,8 +44,7 @@ EOD;
|
||||
<textarea name='data' rows='20' cols='80'>$data</textarea>
|
||||
<br><input type='submit' value='Click to send to Shish'>
|
||||
<br>Your stats are useful so that I know which combinations
|
||||
of web servers / databases / etc I need to support,
|
||||
<br>and so that I can get some idea of how people use shimmie generally
|
||||
of web servers / databases / etc I need to support.
|
||||
</form>
|
||||
EOD;
|
||||
return $html;
|
||||
|
@ -7,7 +7,8 @@
|
||||
*/
|
||||
|
||||
class SendPMEvent extends Event {
|
||||
public function SendPMEvent($from_id, $from_ip, $to_id, $subject, $message) {
|
||||
public function __construct(RequestContext $reqest, $from_id, $from_ip, $to_id, $subject, $message) {
|
||||
parent::__construct($request);
|
||||
$this->from_id = $from_id;
|
||||
$this->from_ip = $from_ip;
|
||||
$this->to_id = $to_id;
|
||||
@ -23,9 +24,8 @@ class PM implements Extension {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof InitExtEvent) {
|
||||
global $config;
|
||||
if($config->get_int("pm_version") < 1) {
|
||||
$this->install();
|
||||
if($event->context->config->get_int("pm_version") < 1) {
|
||||
$this->install($event->context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,22 +38,22 @@ class PM implements Extension {
|
||||
*/
|
||||
|
||||
if($event instanceof UserPageBuildingEvent) {
|
||||
global $user;
|
||||
$duser = $event->user;
|
||||
$user = $event->context->user;
|
||||
$duser = $event->display_user;
|
||||
if(!$user->is_anonymous() && !$duser->is_anonymous()) {
|
||||
if(($user->id == $duser->id) || $user->is_admin()) {
|
||||
$this->theme->display_pms($event->page, $this->get_pms($duser));
|
||||
$this->theme->display_pms($event->context->page, $this->get_pms($duser));
|
||||
}
|
||||
if($user->id != $duser->id) {
|
||||
$this->theme->display_composer($event->page, $user, $duser);
|
||||
$this->theme->display_composer($event->context->page, $user, $duser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("pm")) {
|
||||
global $database;
|
||||
global $config;
|
||||
global $user;
|
||||
$database = $event->context->database;
|
||||
$config = $event->context->config;
|
||||
$user = $event->config->user;
|
||||
if(!$user->is_anonymous()) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "read":
|
||||
@ -91,7 +91,7 @@ class PM implements Extension {
|
||||
$from_id = $user->id;
|
||||
$subject = $_POST["subject"];
|
||||
$message = $_POST["message"];
|
||||
send_event(new SendPMEvent($from_id, $_SERVER["REMOTE_ADDR"], $to_id, $subject, $message));
|
||||
send_event(new SendPMEvent($event->context, $from_id, $_SERVER["REMOTE_ADDR"], $to_id, $subject, $message));
|
||||
$event->page->set_mode("redirect");
|
||||
$event->page->set_redirect(make_link($_SERVER["REFERER"]));
|
||||
break;
|
||||
@ -100,8 +100,7 @@ class PM implements Extension {
|
||||
}
|
||||
|
||||
if($event instanceof SendPMEvent) {
|
||||
global $database;
|
||||
$database->execute("
|
||||
$event->context->database->execute("
|
||||
INSERT INTO private_message(
|
||||
from_id, from_ip, to_id,
|
||||
sent_date, subject, message)
|
||||
@ -112,9 +111,9 @@ class PM implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
protected function install() {
|
||||
global $database;
|
||||
global $config;
|
||||
protected function install(RequestContext $context) {
|
||||
$database = $context->database;
|
||||
$config = $context->config;
|
||||
|
||||
// shortcut to latest
|
||||
if($config->get_int("pm_version") < 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user