Skip to content

Commit

Permalink
Merge branch 'MDL-32009-master-3' of git://git.luns.net.uk/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed May 1, 2012
2 parents 75c9c54 + c9e3499 commit 7c30505
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 9 deletions.
33 changes: 30 additions & 3 deletions admin/message.php
Expand Up @@ -34,6 +34,10 @@
// Get the submitted params
$disable = optional_param('disable', 0, PARAM_INT);
$enable = optional_param('enable', 0, PARAM_INT);
$uninstall = optional_param('uninstall', 0, PARAM_INT);
$confirm = optional_param('confirm', false, PARAM_BOOL);

$headingtitle = get_string('managemessageoutputs', 'message');

if (!empty($disable) && confirm_sesskey()) {
if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
Expand All @@ -42,14 +46,37 @@
$DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
}

if (!empty($enable) && confirm_sesskey() ) {
if (!empty($enable) && confirm_sesskey()) {
if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
print_error('outputdoesnotexist', 'message');
}
$DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
}

if ($disable || $enable) {
if (!empty($uninstall) && confirm_sesskey()) {
echo $OUTPUT->header();
echo $OUTPUT->heading($headingtitle);

if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) {
print_error('outputdoesnotexist', 'message');
}

$processorname = get_string('pluginname', 'message_'.$processor->name);

if (!$confirm) {
echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php');
echo $OUTPUT->footer();
exit;

} else {
message_processor_uninstall($processor->name);
$a->processor = $processorname;
$a->directory = $CFG->dirroot.'/message/output/'.$processor->name;
notice(get_string('processordeletefiles', 'message', $a), 'message.php');
}
}

if ($disable || $enable || $uninstall) {
$url = new moodle_url('message.php');
redirect($url);
}
Expand All @@ -65,6 +92,6 @@

// Display the page
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('managemessageoutputs', 'message'));
echo $OUTPUT->heading($headingtitle);
echo $messageoutputs;
echo $OUTPUT->footer();
4 changes: 3 additions & 1 deletion lang/en/message.php
Expand Up @@ -53,7 +53,7 @@
$string['emailmessages'] = 'Email messages when I am offline';
$string['emailtagline'] = 'This is a copy of a message sent to you at "{$a->sitename}". Go to {$a->url} to reply.';
$string['emptysearchstring'] = 'You must search for something';
$string['errorcallingprocessor'] = 'Error calling defined processor';
$string['errorcallingprocessor'] = 'Error calling defined output';
$string['errortranslatingdefault'] = 'Error translating default setting provided by plugin, using system defaults instead.';
$string['forced'] = 'Forced';
$string['formorethan'] = 'For more than';
Expand Down Expand Up @@ -108,6 +108,8 @@
$string['page-message-x'] = 'Any message pages';
$string['private_config'] = 'Popup message window';
$string['processortag'] = 'Destination';
$string['processordeleteconfirm'] = 'You are about to completely delete message output \'{$a}\'. This will completely delete everything in the database associated with this output. Are you SURE you want to continue?';
$string['processordeletefiles'] = 'All data associated with the output \'{$a->processor}\' has been deleted from the database. To complete the deletion (and prevent the output re-installing itself), you should now delete this directory from your server: {$a->directory}';
$string['providers_config'] = 'Configure notification methods for incoming messages';
$string['providerstag'] = 'Source';
$string['recent'] = 'Recent';
Expand Down
4 changes: 2 additions & 2 deletions lang/en/plugin.php
Expand Up @@ -91,8 +91,8 @@
$string['type_gradingform_plural'] = 'Advanced grading methods';
$string['type_local'] = 'Local plugin';
$string['type_local_plural'] = 'Local plugins';
$string['type_message'] = 'Messaging processor';
$string['type_message_plural'] = 'Messaging processors';
$string['type_message'] = 'Messaging output';
$string['type_message_plural'] = 'Messaging outputs';
$string['type_mnetservice'] = 'MNet service';
$string['type_mnetservice_plural'] = 'MNet services';
$string['type_mod'] = 'Activity module';
Expand Down
1 change: 1 addition & 0 deletions lib/messagelib.php
Expand Up @@ -492,6 +492,7 @@ function message_processor_uninstall($name) {

$transaction = $DB->start_delegated_transaction();
$DB->delete_records('message_processors', array('name' => $name));
$DB->delete_records_select('config_plugins', "plugin = ?", array("message_{$name}"));
// delete permission preferences only, we do not care about loggedin/loggedoff
// defaults, they will be removed on the next attempt to update the preferences
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("{$name}_provider_%"));
Expand Down
32 changes: 29 additions & 3 deletions lib/pluginlib.php
Expand Up @@ -2288,11 +2288,37 @@ public function get_uninstall_url() {
class plugininfo_message extends plugininfo_base {

public function get_settings_url() {
$processors = get_message_processors();
if (isset($processors[$this->name])) {
$processor = $processors[$this->name];
if ($processor->available && $processor->hassettings) {
return new moodle_url('settings.php', array('section' => 'messagesetting'.$processor->name));
}
}
return parent::get_settings_url();
}

if (file_exists($this->full_path('settings.php')) or file_exists($this->full_path('settingstree.php'))) {
return new moodle_url('/admin/settings.php', array('section' => 'messagesetting' . $this->name));
/**
* @see plugintype_interface::is_enabled()
*/
public function is_enabled() {
$processors = get_message_processors();
if (isset($processors[$this->name])) {
return $processors[$this->name]->configured && $processors[$this->name]->enabled;
} else {
return parent::get_settings_url();
return parent::is_enabled();
}
}

/**
* @see plugintype_interface::get_uninstall_url()
*/
public function get_uninstall_url() {
$processors = get_message_processors();
if (isset($processors[$this->name])) {
return new moodle_url('message.php', array('uninstall' => $processors[$this->name]->id, 'sesskey' => sesskey()));
} else {
return parent::get_uninstall_url();
}
}
}
Expand Down

0 comments on commit 7c30505

Please sign in to comment.