aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/ui_forms_plugin.php52
-rw-r--r--classes/ui_tables_plugin.php44
-rw-r--r--db/upgrade.php12
-rw-r--r--index.php32
-rw-r--r--lib.php58
-rw-r--r--service.php50
6 files changed, 124 insertions, 124 deletions
diff --git a/classes/ui_forms_plugin.php b/classes/ui_forms_plugin.php
index 2e60b90..dd5d599 100644
--- a/classes/ui_forms_plugin.php
+++ b/classes/ui_forms_plugin.php
@@ -36,10 +36,10 @@ require_once($CFG->libdir . '/formslib.php');
*/
class local_webhooks_service_edit_form extends moodleform {
/**
- * @param string $base_url
+ * @param string $baseurl
*/
- public function __construct($base_url) {
- parent::__construct($base_url);
+ public function __construct($baseurl) {
+ parent::__construct($baseurl);
}
/**
@@ -48,55 +48,55 @@ class local_webhooks_service_edit_form extends moodleform {
* @throws \coding_exception
*/
protected function definition() {
- $m_form =& $this->_form;
+ $mform =& $this->_form;
$size = array('size' => 60);
/* Form heading */
- $m_form->addElement('header', 'edit-service-header-main', new lang_string('service', 'webservice'));
+ $mform->addElement('header', 'edit-service-header-main', new lang_string('service', 'webservice'));
/* Name of the service */
- $m_form->addElement('text', 'name', new lang_string('name', 'moodle'), $size);
- $m_form->addRule('name', null, 'required');
- $m_form->setType('name', PARAM_RAW);
+ $mform->addElement('text', 'name', new lang_string('name', 'moodle'), $size);
+ $mform->addRule('name', null, 'required');
+ $mform->setType('name', PARAM_RAW);
/* Callback address */
- $m_form->addElement('text', 'point', new lang_string('url', 'moodle'), $size);
- $m_form->addRule('point', null, 'required');
- $m_form->setType('point', PARAM_URL);
+ $mform->addElement('text', 'point', new lang_string('url', 'moodle'), $size);
+ $mform->addRule('point', null, 'required');
+ $mform->setType('point', PARAM_URL);
/* Enabling the service */
- $m_form->addElement('advcheckbox', 'status', new lang_string('enable', 'moodle'));
- $m_form->setType('status', PARAM_BOOL);
- $m_form->setDefault('status', 1);
- $m_form->setAdvanced('status');
+ $mform->addElement('advcheckbox', 'status', new lang_string('enable', 'moodle'));
+ $mform->setType('status', PARAM_BOOL);
+ $mform->setDefault('status', 1);
+ $mform->setAdvanced('status');
/* Token */
- $m_form->addElement('text', 'token', new lang_string('token', 'webservice'), $size);
- $m_form->addRule('token', null, 'required');
- $m_form->setType('token', PARAM_RAW);
+ $mform->addElement('text', 'token', new lang_string('token', 'webservice'), $size);
+ $mform->addRule('token', null, 'required');
+ $mform->setType('token', PARAM_RAW);
/* Content type */
- $content_type = array(
+ $contenttype = array(
'application/json' => 'application/json',
'application/x-www-form-urlencoded' => 'application/x-www-form-urlencoded',
);
- $m_form->addElement('select', 'header', 'Content-Type', $content_type);
- $m_form->setAdvanced('header');
+ $mform->addElement('select', 'header', 'Content-Type', $contenttype);
+ $mform->setAdvanced('header');
/* Form heading */
- $m_form->addElement('header', 'edit-service-header-event', new lang_string('edulevel', 'moodle'));
+ $mform->addElement('header', 'edit-service-header-event', new lang_string('edulevel', 'moodle'));
/* List of events */
- $event_list = report_eventlist_list_generator::get_all_events_list(true);
+ $eventlist = report_eventlist_list_generator::get_all_events_list(true);
$events = array();
- foreach ($event_list as $event) {
- $events[$event['component']][] =& $m_form->createElement('checkbox', $event['eventname'], $event['eventname']);
+ foreach ($eventlist as $event) {
+ $events[$event['component']][] =& $mform->createElement('checkbox', $event['eventname'], $event['eventname']);
}
foreach ($events as $key => $event) {
- $m_form->addGroup($event, 'events', $key, '<br />', true);
+ $mform->addGroup($event, 'events', $key, '<br />', true);
}
/* Control Panel */
diff --git a/classes/ui_tables_plugin.php b/classes/ui_tables_plugin.php
index d08d3db..f65d3fe 100644
--- a/classes/ui_tables_plugin.php
+++ b/classes/ui_tables_plugin.php
@@ -36,24 +36,24 @@ require_once($CFG->libdir . '/tablelib.php');
*/
class local_webhooks_services_table extends table_sql {
/**
- * @var string $main_page
+ * @var string $mainpage
*/
- protected static $main_page = '/local/webhooks/index.php';
+ protected static $mainpage = '/local/webhooks/index.php';
/**
- * @var string $editor_page
+ * @var string $editorpage
*/
- protected static $editor_page = '/local/webhooks/service.php';
+ protected static $editorpage = '/local/webhooks/service.php';
/**
* Constructor.
*
- * @param string $unique_id
+ * @param string $uniqueid
*
* @throws \coding_exception
*/
- public function __construct($unique_id = '') {
- parent::__construct($unique_id);
+ public function __construct($uniqueid = '') {
+ parent::__construct($uniqueid);
$this->define_table_columns();
$this->define_table_configs();
}
@@ -61,12 +61,12 @@ class local_webhooks_services_table extends table_sql {
/**
* Query the database for results to display in the table.
*
- * @param int $page_size
- * @param boolean $use_initials_bar
+ * @param int $pagesize
+ * @param boolean $useinitialsbar
*
* @throws \dml_exception
*/
- public function query_db($page_size = 0, $use_initials_bar = false) {
+ public function query_db($pagesize = 0, $useinitialsbar = false) {
$this->rawdata = local_webhooks_api::get_services(array(), $this->get_page_start(), $this->get_page_size());
}
@@ -116,27 +116,27 @@ class local_webhooks_services_table extends table_sql {
public function col_actions($row) {
global $OUTPUT;
- $hide_show_icon = 't/show';
- $hide_show_string = new lang_string('enable', 'moodle');
+ $hideshowicon = 't/show';
+ $hideshowstring = new lang_string('enable', 'moodle');
if (!empty($row->status)) {
- $hide_show_icon = 't/hide';
- $hide_show_string = new lang_string('disable', 'moodle');
+ $hideshowicon = 't/hide';
+ $hideshowstring = new lang_string('disable', 'moodle');
}
/* Link for activation / deactivation */
- $hide_show_link = new moodle_url(self::$main_page, array('hideshowid' => $row->id, 'sesskey' => sesskey()));
- $hide_show_item = $OUTPUT->action_icon($hide_show_link, new pix_icon($hide_show_icon, $hide_show_string));
+ $hideshowlink = new moodle_url(self::$mainpage, array('hideshowid' => $row->id, 'sesskey' => sesskey()));
+ $hideshowitem = $OUTPUT->action_icon($hideshowlink, new pix_icon($hideshowicon, $hideshowstring));
/* Link for editing */
- $edit_link = new moodle_url(self::$editor_page, array('serviceid' => $row->id, 'sesskey' => sesskey()));
- $edit_item = $OUTPUT->action_icon($edit_link, new pix_icon('t/edit', new lang_string('edit', 'moodle')));
+ $editlink = new moodle_url(self::$editorpage, array('serviceid' => $row->id, 'sesskey' => sesskey()));
+ $edititem = $OUTPUT->action_icon($editlink, new pix_icon('t/edit', new lang_string('edit', 'moodle')));
/* Link to remove */
- $delete_link = new moodle_url(self::$main_page, array('deleteid' => $row->id, 'sesskey' => sesskey()));
- $delete_item = $OUTPUT->action_icon($delete_link, new pix_icon('t/delete', new lang_string('delete', 'moodle')));
+ $deletelink = new moodle_url(self::$mainpage, array('deleteid' => $row->id, 'sesskey' => sesskey()));
+ $deleteitem = $OUTPUT->action_icon($deletelink, new pix_icon('t/delete', new lang_string('delete', 'moodle')));
- return $hide_show_item . $edit_item . $delete_item;
+ return $hideshowitem . $edititem . $deleteitem;
}
/**
@@ -159,7 +159,7 @@ class local_webhooks_services_table extends table_sql {
* @throws \moodle_exception
*/
public function col_name($row) {
- $link = new moodle_url(self::$editor_page, array('serviceid' => $row->id, 'sesskey' => sesskey()));
+ $link = new moodle_url(self::$editorpage, array('serviceid' => $row->id, 'sesskey' => sesskey()));
return html_writer::link($link, $row->name);
}
diff --git a/db/upgrade.php b/db/upgrade.php
index 968c32e..d47312d 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -27,18 +27,18 @@ defined('MOODLE_INTERNAL') || die();
/**
* Function to upgrade 'local_webhooks'.
*
- * @param int $old_version
+ * @param int $oldversion
*
* @return boolean
* @throws \dml_exception
* @throws \downgrade_exception
* @throws \upgrade_exception
*/
-function xmldb_local_webhooks_upgrade($old_version = 0) {
+function xmldb_local_webhooks_upgrade($oldversion = 0) {
global $DB;
/* Update from versions 3.* */
- if ($old_version < 2017112600 || $old_version === 2018061900) {
+ if ($oldversion < 2017112600 || $oldversion === 2018061900) {
$rs = $DB->get_recordset('local_webhooks_service', null, 'id', '*', 0, 0);
foreach ($rs as $record) {
@@ -55,15 +55,15 @@ function xmldb_local_webhooks_upgrade($old_version = 0) {
/* Update from version 4.0.0-rc.1 */
- /* if ($old_version === 2017122900) {} */
+ /* if ($oldversion === 2017122900) {} */
/* Update from version 4.0.0-rc.2 */
- /* if ($old_version === 2018022200) {} */
+ /* if ($oldversion === 2018022200) {} */
/* Update from version 4.0.0-rc.3 */
- /* if ($old_version === 2018022500) {} */
+ /* if ($oldversion === 2018022500) {} */
return true;
} \ No newline at end of file
diff --git a/index.php b/index.php
index 1fe726c..136db73 100644
--- a/index.php
+++ b/index.php
@@ -28,47 +28,47 @@ require_once($CFG->dirroot . '/local/webhooks/classes/ui_tables_plugin.php');
require_once($CFG->dirroot . '/local/webhooks/lib.php');
require_once($CFG->libdir . '/adminlib.php');
-$delete_id = optional_param('deleteid', 0, PARAM_INT);
-$hide_show_id = optional_param('hideshowid', 0, PARAM_INT);
+$deleteid = optional_param('deleteid', 0, PARAM_INT);
+$hideshowid = optional_param('hideshowid', 0, PARAM_INT);
-$edit_page = '/local/webhooks/service.php';
-$main_page = '/local/webhooks/index.php';
-$base_url = new moodle_url($main_page);
+$editpage = '/local/webhooks/service.php';
+$mainpage = '/local/webhooks/index.php';
+$baseurl = new moodle_url($mainpage);
-admin_externalpage_setup('local_webhooks', '', null, $base_url, array());
+admin_externalpage_setup('local_webhooks', '', null, $baseurl, array());
$context = context_system::instance();
/* Remove the service */
-if (!empty($delete_id) && confirm_sesskey()) {
- local_webhooks_api::delete_service($delete_id);
+if (!empty($deleteid) && confirm_sesskey()) {
+ local_webhooks_api::delete_service($deleteid);
redirect($PAGE->url, new lang_string('deleted', 'moodle'));
}
/* Disable / Enable the service */
-if (!empty($hide_show_id) && confirm_sesskey()) {
- $service = local_webhooks_api::get_service($hide_show_id);
+if (!empty($hideshowid) && confirm_sesskey()) {
+ $service = local_webhooks_api::get_service($hideshowid);
$service->status = !(bool) $service->status;
local_webhooks_api::update_service((array) $service);
redirect($PAGE->url, new lang_string('changessaved', 'moodle'));
}
/* The page title */
-$title_page = new lang_string('pluginname', 'local_webhooks');
-$PAGE->set_heading($title_page);
-$PAGE->set_title($title_page);
+$titlepage = new lang_string('pluginname', 'local_webhooks');
+$PAGE->set_heading($titlepage);
+$PAGE->set_title($titlepage);
echo $OUTPUT->header();
/* Displays the table */
$table = new local_webhooks_services_table('local-webhooks-table');
-$table->define_baseurl($base_url);
+$table->define_baseurl($baseurl);
$table->out(25, true);
/* Separation */
echo html_writer::empty_tag('br');
/* Adds the add button */
-$add_service_url = new moodle_url($edit_page, array('sesskey' => sesskey()));
-echo $OUTPUT->single_button($add_service_url, new lang_string('add', 'moodle'));
+$addserviceurl = new moodle_url($editpage, array('sesskey' => sesskey()));
+echo $OUTPUT->single_button($addserviceurl, new lang_string('add', 'moodle'));
/* Footer */
echo $OUTPUT->footer(); \ No newline at end of file
diff --git a/lib.php b/lib.php
index 3db1eea..aefb783 100644
--- a/lib.php
+++ b/lib.php
@@ -38,21 +38,21 @@ class local_webhooks_api {
/**
* Get information about the service.
*
- * @param int $service_id
+ * @param int $serviceid
*
* @return object
* @throws \dml_exception
* @throws \moodle_exception
*/
- public static function get_service($service_id = 0) {
+ public static function get_service($serviceid = 0) {
global $DB;
- if (!is_numeric($service_id) || $service_id === 0) {
- print_error('unknowparamtype', 'error', null, 'service_id');
+ if (!is_numeric($serviceid) || $serviceid === 0) {
+ print_error('unknowparamtype', 'error', null, 'serviceid');
}
- $service = $DB->get_record(LW_TABLE_SERVICES, array('id' => $service_id), '*', MUST_EXIST);
- $events = $DB->get_records(LW_TABLE_EVENTS, array('serviceid' => $service_id), '', '*', 0, 0);
+ $service = $DB->get_record(LW_TABLE_SERVICES, array('id' => $serviceid), '*', MUST_EXIST);
+ $events = $DB->get_records(LW_TABLE_EVENTS, array('serviceid' => $serviceid), '', '*', 0, 0);
$service->events = array();
foreach ($events as $event) {
@@ -67,16 +67,16 @@ class local_webhooks_api {
* By default, the entire list of services is given.
*
* @param array $conditions
- * @param int $limit_from
- * @param int $limit_num
+ * @param int $limitfrom
+ * @param int $limitnum
*
* @return array
* @throws \dml_exception
*/
- public static function get_services(array $conditions = array(), $limit_from = 0, $limit_num = 0) {
+ public static function get_services(array $conditions = array(), $limitfrom = 0, $limitnum = 0) {
global $DB;
- $services = $DB->get_records(LW_TABLE_SERVICES, $conditions, '', '*', $limit_from, $limit_num);
+ $services = $DB->get_records(LW_TABLE_SERVICES, $conditions, '', '*', $limitfrom, $limitnum);
foreach ($services as $service) {
$events = $DB->get_records(LW_TABLE_EVENTS, array('serviceid' => $service->id), '', '*', 0, 0);
@@ -93,20 +93,20 @@ class local_webhooks_api {
/**
* Get the list of services subscribed to the event.
*
- * @param string $event_name
+ * @param string $eventname
*
* @return array
* @throws \dml_exception
* @throws \moodle_exception
*/
- public static function get_services_by_event($event_name = '') {
+ public static function get_services_by_event($eventname = '') {
global $DB;
- if (!is_string($event_name) || $event_name === '') {
- print_error('unknowparamtype', 'error', null, 'event_name');
+ if (!is_string($eventname) || $eventname === '') {
+ print_error('unknowparamtype', 'error', null, 'eventname');
}
- $events = $DB->get_records(LW_TABLE_EVENTS, array('name' => $event_name), '', '*', 0, 0);
+ $events = $DB->get_records(LW_TABLE_EVENTS, array('name' => $eventname), '', '*', 0, 0);
$services = array();
foreach ($events as $event) {
@@ -132,37 +132,37 @@ class local_webhooks_api {
print_error('unknowparamtype', 'error', null, 'service');
}
- $service_id = $DB->insert_record(LW_TABLE_SERVICES, (object) $service, true, false);
- if ($service_id && !empty($service['events']) && is_array($service['events'])) {
- self::insert_events($service['events'], $service_id);
+ $serviceid = $DB->insert_record(LW_TABLE_SERVICES, (object) $service, true, false);
+ if ($serviceid && !empty($service['events']) && is_array($service['events'])) {
+ self::insert_events($service['events'], $serviceid);
}
// TODO: Mark the log.
- return (int) $service_id;
+ return (int) $serviceid;
}
/**
* Delete the service data from the database.
*
- * @param int $service_id
+ * @param int $serviceid
*
* @return bool
* @throws \dml_exception
* @throws \moodle_exception
*/
- public static function delete_service($service_id = 0) {
+ public static function delete_service($serviceid = 0) {
global $DB;
- if (!is_numeric($service_id) || $service_id === 0) {
- print_error('unknowparamtype', 'error', null, 'service_id');
+ if (!is_numeric($serviceid) || $serviceid === 0) {
+ print_error('unknowparamtype', 'error', null, 'serviceid');
}
// TODO: Mark the log.
- $DB->delete_records(LW_TABLE_EVENTS, array('serviceid' => $service_id));
+ $DB->delete_records(LW_TABLE_EVENTS, array('serviceid' => $serviceid));
- return $DB->delete_records(LW_TABLE_SERVICES, array('id' => $service_id));
+ return $DB->delete_records(LW_TABLE_SERVICES, array('id' => $serviceid));
}
/**
@@ -198,17 +198,17 @@ class local_webhooks_api {
* Save the list of events to the database.
*
* @param array $events
- * @param int $service_id
+ * @param int $serviceid
*
* @throws \coding_exception
* @throws \dml_exception
*/
- protected static function insert_events(array $events = array(), $service_id = 0) {
+ protected static function insert_events(array $events = array(), $serviceid = 0) {
global $DB;
$conditions = array();
- foreach ($events as $event_name) {
- $conditions[] = array('name' => $event_name, 'serviceid' => $service_id);
+ foreach ($events as $eventname) {
+ $conditions[] = array('name' => $eventname, 'serviceid' => $serviceid);
}
$DB->insert_records(LW_TABLE_EVENTS, $conditions);
diff --git a/service.php b/service.php
index 224e3e4..5c18ee8 100644
--- a/service.php
+++ b/service.php
@@ -28,55 +28,55 @@ require_once($CFG->dirroot . '/local/webhooks/classes/ui_forms_plugin.php');
require_once($CFG->dirroot . '/local/webhooks/lib.php');
require_once($CFG->libdir . '/adminlib.php');
-$service_id = optional_param('serviceid', 0, PARAM_INT);
+$serviceid = optional_param('serviceid', 0, PARAM_INT);
-$url_parameters = array('serviceid' => $service_id);
-$base_url = new moodle_url('/local/webhooks/service.php', $url_parameters);
-$main_page = new moodle_url('/local/webhooks/index.php');
+$urlparameters = array('serviceid' => $serviceid);
+$baseurl = new moodle_url('/local/webhooks/service.php', $urlparameters);
+$mainpage = new moodle_url('/local/webhooks/index.php');
-admin_externalpage_setup('local_webhooks', '', null, $base_url, array());
+admin_externalpage_setup('local_webhooks', '', null, $baseurl, array());
$context = context_system::instance();
-$m_form = new local_webhooks_service_edit_form($PAGE->url);
-$form_data = (array) $m_form->get_data();
+$mform = new local_webhooks_service_edit_form($PAGE->url);
+$formdata = (array) $mform->get_data();
/* Cancel */
-if ($m_form->is_cancelled()) {
- redirect($main_page);
+if ($mform->is_cancelled()) {
+ redirect($mainpage);
}
/* Updating the data */
-if (!empty($form_data) && confirm_sesskey()) {
- if (isset($form_data['events'])) {
- $form_data['events'] = array_keys($form_data['events']);
+if (!empty($formdata) && confirm_sesskey()) {
+ if (isset($formdata['events'])) {
+ $formdata['events'] = array_keys($formdata['events']);
}
- if (!empty($service_id)) {
- $form_data['id'] = $service_id;
- local_webhooks_api::update_service($form_data);
+ if (!empty($serviceid)) {
+ $formdata['id'] = $serviceid;
+ local_webhooks_api::update_service($formdata);
} else {
- local_webhooks_api::create_service($form_data);
+ local_webhooks_api::create_service($formdata);
}
- redirect($main_page, new lang_string('changessaved', 'moodle'));
+ redirect($mainpage, new lang_string('changessaved', 'moodle'));
}
/* Loading service data */
-if (!empty($service_id)) {
- $service = local_webhooks_api::get_service($service_id);
+if (!empty($serviceid)) {
+ $service = local_webhooks_api::get_service($serviceid);
$service->events = array_fill_keys($service->events, 1);
- $m_form->set_data($service);
+ $mform->set_data($service);
}
/* The page title */
-$title_page = new lang_string('externalservice', 'webservice');
-$PAGE->navbar->add($title_page);
-$PAGE->set_heading($title_page);
-$PAGE->set_title($title_page);
+$titlepage = new lang_string('externalservice', 'webservice');
+$PAGE->navbar->add($titlepage);
+$PAGE->set_heading($titlepage);
+$PAGE->set_title($titlepage);
echo $OUTPUT->header();
/* Displays the form */
-$m_form->display();
+$mform->display();
/* Footer */
echo $OUTPUT->footer(); \ No newline at end of file