-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev Fixed internal server error when no logging is used.
Dev Added new plugin. Dev Added plugin-survey settings...
- Loading branch information
Sam
committed
Jan 24, 2013
1 parent
f1ba544
commit c4acc85
Showing
10 changed files
with
210 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
<div id="plugin-<?php echo $plugin['name']; ?>"> | ||
<h1>Settings for plugin "<?php echo $plugin['name']; ?>".</h1> | ||
<div class="pluginsettings"> | ||
<?php | ||
|
||
Yii::import("application.helpers.PluginSettingsHelper"); | ||
$PluginSettings = new PluginSettingsHelper(); | ||
|
||
echo CHtml::beginForm('', 'post', array('id' => "pluginsettings-{$plugin['name']}")); | ||
|
||
<h1>Settings for plugin "<?php echo $plugin['name']; ?>".</h1> | ||
<div class="pluginsettings"> | ||
<?php | ||
foreach ($settings as $name => $setting) | ||
{ | ||
$PluginSettings->renderSetting($name, $setting, "pluginsettings-{$plugin['name']}"); | ||
} | ||
echo CHtml::submitButton('Save plugin settings'); | ||
echo CHtml::endForm(); | ||
|
||
// @var PluginsController Description | ||
$this; | ||
|
||
echo CHtml::beginForm('', 'post', array('id' => 'pluginsettings')); | ||
|
||
foreach ($settings as $name => $setting) | ||
{ | ||
$this->PluginSettings->renderSetting($name, $setting, 'pluginsettings'); | ||
} | ||
echo CHtml::submitButton('Save plugin settings'); | ||
echo CHtml::endForm(); | ||
|
||
?> | ||
?> | ||
|
||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
class Maintenance extends PluginBase | ||
{ | ||
|
||
protected $storage = 'DbStorage'; | ||
static protected $description = 'Maintenance mode plugin'; | ||
|
||
protected $settings = array( | ||
'maintenance' => array( | ||
'type' => 'boolean', | ||
'label' => 'Enable maintence mode:' | ||
), | ||
'message' => array( | ||
'type' => 'string', | ||
'label' => 'Message to show to users:' | ||
) | ||
); | ||
|
||
/** | ||
* Here you should handle subscribing to the events your plugin will handle | ||
*/ | ||
public function registerEvents() { | ||
// Only describe to events if in maintenance mode. | ||
if ($this->get('maintenance') == 1) | ||
{ | ||
$this->subscribe('beforeLogin'); | ||
$this->subscribe('beforeSurveyController'); | ||
} | ||
} | ||
|
||
public function __construct(PluginManager $pluginManager, $id) | ||
{ | ||
parent::__construct($pluginManager, $id); | ||
} | ||
|
||
|
||
public function beforeLogin(PluginEvent $event) | ||
{ | ||
if ($this->get('maintenance') == 1) | ||
{ | ||
$user = $event->get('user'); | ||
if ($user == null || $user->superadmin != 1) | ||
{ | ||
Yii::app()->session['flashmessage'] = 'Login denied for non-super-users. Maintenance mode is active.'; | ||
$event->stop(); | ||
} | ||
} | ||
} | ||
|
||
public function beforeSurveyController(PluginEvent $event) | ||
{ | ||
$event->stop(); | ||
// Render an alternative view. | ||
echo $this->get('message'); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
?> |