Hello, I started doing plugins for moodle at php but now that I've been asked to develop an editor plugin i'm having some problems since i am not quite familiar with js, and not familiar at all with YUI.
Scenario: I have to insert some data into moodle database. It'll be part of a suggestion system. A button at edditor will save user suggestion at database. (The activity need to be at editor because I have developed some repository plugins and this will be part of the plugin family)
I'm running tests at localhost.
Here's the php code:
<?php
define('AJAX_SCRIPT', true);
define('NO_MOODLE_COOKIES', true);
require_once(dirname(dirname(dirname(__DIR__))) . '/config.php');
global $DB;
function dbAcess($parametro){
$record = new stdClass();
$record->sugestion = $parametro;
$lastinsertid = $DB->insert_record($parametro, $record, false);
return $lastinsertid;
}
Here's what i'm struggling with (yui io call):
_submitData: function(e) {
e.preventDefault();
this.getDialogue({
focusAfterHide: null
}).hide();
//receive sugestion from textbox
var sugestion = form.one(SELECTORS.SUGESTINPUT).get('value');
Y.io(M.cfg.wwwroot + '/lib/editor/atto/plugins/alexandria/db.php', {
context: this,
on: {
sucess: function() {
var host = this.get('host');
var sugestionHtml = '<p>' + 'Suggestion recorded + '</p>';
host.insertContentAtFocusPoint(sugestionHtml);
this.markUpdated();
return;
}
}
});
}
How do I make this function to work? I need the to call the method at php file passing the var sugestion and receive the last inserted id from php as result.
Any help is welcome, Thanks.
Marcus