From 7f9b07d8c9840944ea7ebf437f45e44584bcb5ee Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 24 Dec 2009 15:25:59 -0600 Subject: Move ssl settings from site admin panel to paths admin panel --- actions/pathsadminpanel.php | 34 ++++++++++++++++++++++++++++++++-- actions/siteadminpanel.php | 31 +------------------------------ 2 files changed, 33 insertions(+), 32 deletions(-) (limited to 'actions') diff --git a/actions/pathsadminpanel.php b/actions/pathsadminpanel.php index f1a2b1b8a..c6daa1734 100644 --- a/actions/pathsadminpanel.php +++ b/actions/pathsadminpanel.php @@ -92,7 +92,7 @@ class PathsadminpanelAction extends AdminPanelAction function saveSettings() { static $settings = array( - 'site' => array('path', 'locale_path'), + 'site' => array('path', 'locale_path', 'ssl', 'sslserver'), 'theme' => array('server', 'dir', 'path'), 'avatar' => array('server', 'dir', 'path'), 'background' => array('server', 'dir', 'path') @@ -160,6 +160,14 @@ class PathsadminpanelAction extends AdminPanelAction $this->clientError(sprintf(_("Locales directory not readable: %s"), $values['site']['locale_path'])); } + // Validate SSL setup + + if (in_array($values['site']['ssl'], array('sometimes', 'always'))) { + if (empty($values['site']['sslserver'])) { + $this->clientError(_("You must set an SSL server when enabling SSL.")); + } + } + } } @@ -283,6 +291,29 @@ class PathsAdminPanelForm extends AdminForm $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); + + $this->out->elementStart('fieldset', array('id' => 'settings_admin_ssl')); + $this->out->element('legend', null, _('SSL')); + $this->out->elementStart('ul', 'form_data'); + $this->li(); + $ssl = array('never' => _('Never'), + 'sometimes' => _('Sometimes'), + 'always' => _('Always')); + + common_debug("site ssl = " . $this->value('site', 'ssl')); + + $this->out->dropdown('site-ssl', _('Use SSL'), + $ssl, _('When to use SSL'), + false, $this->value('ssl', 'site')); + $this->unli(); + + $this->li(); + $this->input('sslserver', _('SSL Server'), + _('Server to direct SSL requests to'), 'site'); + $this->unli(); + $this->out->elementEnd('ul'); + $this->out->elementEnd('fieldset'); + } /** @@ -297,7 +328,6 @@ class PathsAdminPanelForm extends AdminForm 'save', _('Save paths')); } - /** * Utility to simplify some of the duplicated code around * params and settings. Overriding the input() in the base class diff --git a/actions/siteadminpanel.php b/actions/siteadminpanel.php index b963336e6..f260a4476 100644 --- a/actions/siteadminpanel.php +++ b/actions/siteadminpanel.php @@ -92,8 +92,7 @@ class SiteadminpanelAction extends AdminPanelAction { static $settings = array('site' => array('name', 'broughtby', 'broughtbyurl', 'email', 'timezone', 'language', - 'ssl', 'sslserver', 'site', - 'textlimit', 'dupelimit'), + 'site', 'textlimit', 'dupelimit'), 'snapshot' => array('run', 'reporturl', 'frequency')); static $booleans = array('site' => array('private', 'inviteonly', 'closed', 'fancy')); @@ -192,14 +191,6 @@ class SiteadminpanelAction extends AdminPanelAction $this->clientError(_("Snapshot frequency must be a number.")); } - // Validate SSL setup - - if (in_array($values['site']['ssl'], array('sometimes', 'always'))) { - if (empty($values['site']['sslserver'])) { - $this->clientError(_("You must set an SSL server when enabling SSL.")); - } - } - if (mb_strlen($values['site']['sslserver']) > 255) { $this->clientError(_("Invalid SSL server. The maximum length is 255 characters.")); } @@ -376,26 +367,6 @@ class SiteAdminPanelForm extends AdminForm $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); - $this->out->elementStart('fieldset', array('id' => 'settings_admin_ssl')); - $this->out->element('legend', null, _('SSL')); - $this->out->elementStart('ul', 'form_data'); - $this->li(); - $ssl = array('never' => _('Never'), - 'sometimes' => _('Sometimes'), - 'always' => _('Always')); - - $this->out->dropdown('ssl', _('Use SSL'), - $ssl, _('When to use SSL'), - false, $this->value('ssl', 'site')); - $this->unli(); - - $this->li(); - $this->input('sslserver', _('SSL Server'), - _('Server to direct SSL requests to')); - $this->unli(); - $this->out->elementEnd('ul'); - $this->out->elementEnd('fieldset'); - $this->out->elementStart('fieldset', array('id' => 'settings_admin_limits')); $this->out->element('legend', null, _('Limits')); $this->out->elementStart('ul', 'form_data'); -- cgit v1.2.3-54-g00ecf From 1a462b04d7594159e90b514538ddbe3f7effd7f8 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 24 Dec 2009 16:50:28 -0600 Subject: Paths admin panel should not insist on an ssl server being specified, ever. --- actions/pathsadminpanel.php | 7 ++----- actions/siteadminpanel.php | 4 ---- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'actions') diff --git a/actions/pathsadminpanel.php b/actions/pathsadminpanel.php index c6daa1734..d39c7c449 100644 --- a/actions/pathsadminpanel.php +++ b/actions/pathsadminpanel.php @@ -162,12 +162,9 @@ class PathsadminpanelAction extends AdminPanelAction // Validate SSL setup - if (in_array($values['site']['ssl'], array('sometimes', 'always'))) { - if (empty($values['site']['sslserver'])) { - $this->clientError(_("You must set an SSL server when enabling SSL.")); - } + if (mb_strlen($values['site']['sslserver']) > 255) { + $this->clientError(_("Invalid SSL server. The maximum length is 255 characters.")); } - } } diff --git a/actions/siteadminpanel.php b/actions/siteadminpanel.php index f260a4476..5e29f4c19 100644 --- a/actions/siteadminpanel.php +++ b/actions/siteadminpanel.php @@ -191,10 +191,6 @@ class SiteadminpanelAction extends AdminPanelAction $this->clientError(_("Snapshot frequency must be a number.")); } - if (mb_strlen($values['site']['sslserver']) > 255) { - $this->clientError(_("Invalid SSL server. The maximum length is 255 characters.")); - } - // Validate text limit if (!Validate::number($values['site']['textlimit'], array('min' => 140))) { -- cgit v1.2.3-54-g00ecf From c5de3262312f814bc44e596d9031c2df22420e27 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 28 Dec 2009 10:42:55 -0800 Subject: events for blocking a user --- EVENTS.txt | 7 +++++++ actions/apiblockcreate.php | 13 ++++++++++--- actions/block.php | 8 ++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'actions') diff --git a/EVENTS.txt b/EVENTS.txt index 96250f64c..42aecfaf9 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -640,3 +640,10 @@ EndLog: After writing to the logs - $msg - $filename +StartBlockProfile: when we're about to block +- $user: the person doing the block +- $profile: the person getting blocked, can be remote + +EndBlockProfile: when a block has succeeded +- $user: the person doing the block +- $profile: the person blocked, can be remote diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php index e79dec32d..c26485f59 100644 --- a/actions/apiblockcreate.php +++ b/actions/apiblockcreate.php @@ -109,9 +109,16 @@ class ApiBlockCreateAction extends ApiAuthAction return; } - if ($this->user->hasBlocked($this->other) - || $this->user->block($this->other) - ) { + if (!$this->user->hasBlocked($this->other)) { + if (Event::handle('StartBlockProfile', array($this->user, $this->other))) { + $result = $this->user->block($this->other); + if ($result) { + Event::handle('EndBlockProfile', array($this->user, $this->other)); + } + } + } + + if ($this->user->hasBlocked($this->other)) { $this->initDocument($this->format); $this->showProfile($this->other, $this->format); $this->endDocument($this->format); diff --git a/actions/block.php b/actions/block.php index 71a34e087..5fae45dff 100644 --- a/actions/block.php +++ b/actions/block.php @@ -156,7 +156,12 @@ class BlockAction extends ProfileFormAction { $cur = common_current_user(); - $result = $cur->block($this->profile); + if (Event::handle('StartBlockProfile', array($cur, $this->profile))) { + $result = $cur->block($this->profile); + if ($result) { + Event::handle('EndBlockProfile', array($cur, $this->profile)); + } + } if (!$result) { $this->serverError(_('Failed to save block information.')); @@ -164,4 +169,3 @@ class BlockAction extends ProfileFormAction } } } - -- cgit v1.2.3-54-g00ecf From 2ae04bb6d598c74763aca79ab52172934158be46 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 28 Dec 2009 10:50:12 -0800 Subject: add events for unblocking a profile --- EVENTS.txt | 8 ++++++++ actions/apiblockdestroy.php | 13 ++++++++++--- actions/unblock.php | 13 +++++++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) (limited to 'actions') diff --git a/EVENTS.txt b/EVENTS.txt index 42aecfaf9..64e345b69 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -647,3 +647,11 @@ StartBlockProfile: when we're about to block EndBlockProfile: when a block has succeeded - $user: the person doing the block - $profile: the person blocked, can be remote + +StartUnblockProfile: when we're about to unblock +- $user: the person doing the unblock +- $profile: the person getting unblocked, can be remote + +EndUnblockProfile: when an unblock has succeeded +- $user: the person doing the unblock +- $profile: the person unblocked, can be remote diff --git a/actions/apiblockdestroy.php b/actions/apiblockdestroy.php index 328f18ab0..666f308f4 100644 --- a/actions/apiblockdestroy.php +++ b/actions/apiblockdestroy.php @@ -97,9 +97,16 @@ class ApiBlockDestroyAction extends ApiAuthAction return; } - if (!$this->user->hasBlocked($this->other) - || $this->user->unblock($this->other) - ) { + if ($this->user->hasBlocked($this->other)) { + if (Event::handle('StartUnblockProfile', array($this->user, $this->other))) { + $result = $this->user->unblock($this->other); + if ($result) { + Event::handle('EndUnblockProfile', array($this->user, $this->other)); + } + } + } + + if (!$this->user->hasBlocked($this->other)) { $this->initDocument($this->format); $this->showProfile($this->other, $this->format); $this->endDocument($this->format); diff --git a/actions/unblock.php b/actions/unblock.php index c60458cd3..0f63e1dae 100644 --- a/actions/unblock.php +++ b/actions/unblock.php @@ -71,8 +71,17 @@ class UnblockAction extends ProfileFormAction function handlePost() { - $cur = common_current_user(); - $result = $cur->unblock($this->profile); + $cur = common_current_user(); + + $result = false; + + if (Event::handle('StartUnblockProfile', array($cur, $this->profile))) { + $result = $cur->unblock($this->profile); + if ($result) { + Event::handle('EndUnblockProfile', array($cur, $this->profile)); + } + } + if (!$result) { $this->serverError(_('Error removing the block.')); return; -- cgit v1.2.3-54-g00ecf