diff --git a/admin/webservice/service_functions.php b/admin/webservice/service_functions.php index 6e610e37fa6..8126288d442 100644 --- a/admin/webservice/service_functions.php +++ b/admin/webservice/service_functions.php @@ -118,7 +118,7 @@ switch ($action) { /// OUTPUT function list page echo $OUTPUT->header(); -echo $OUTPUT->heading($service->name); +echo $OUTPUT->heading(get_string('addservicefunction', 'webservice', $service->name)); $functions = $webservicemanager->get_external_functions(array($service->id)); echo $renderer->admin_service_function_list($functions, $service); echo $OUTPUT->footer(); diff --git a/lang/en/webservice.php b/lang/en/webservice.php index 84d5d43caf2..8bfbcfcca85 100644 --- a/lang/en/webservice.php +++ b/lang/en/webservice.php @@ -35,6 +35,7 @@ $string['addfunctions'] = 'Add functions'; $string['addfunctionsdescription'] = 'On the Manage service page, click the Functions link for the newly created service. Add some functions to the service.'; $string['addrequiredcapability'] = 'Assign/Unassign the required capability'; $string['addservice'] = 'Add a new service: {$a->name} (id: {$a->id})'; +$string['addservicefunction'] = 'Add functions to the service "{$a}"'; $string['allusers'] = 'All users'; $string['amftestclient'] = 'AMF test client'; $string['apiexplorer'] = 'API explorer'; @@ -110,6 +111,7 @@ $string['missingcaps_help'] = 'List of capabilities that the service functions r

Note: in rare case some of these "required" capabilities could depend of a function use case. For example \'moodle_role_get_enrolled_users\' function requires \'moodle/site:viewparticipants\' capability only for a site-wide request.'; $string['missingpassword'] = 'Missing password'; $string['missingusername'] = 'Missing username'; +$string['nofunctions'] = 'This service has no functions.'; $string['norequiredcapability'] = 'No required capability'; $string['notoken'] = 'The token list is empty.'; $string['onesystemcontrolling'] = 'One system controlling Moodle with token'; diff --git a/theme/canvas/style/admin.css b/theme/canvas/style/admin.css index 5a4752e2a2c..650dcf86aa1 100644 --- a/theme/canvas/style/admin.css +++ b/theme/canvas/style/admin.css @@ -121,4 +121,4 @@ */ #page-admin-webservice-service_users .missingcaps {color: #ff6600;font-size: 90%;} #page-admin-setting-webservicetokens .missingcaps {color: #ff6600;font-size: 90%;} -#page-admin-websevice-service_functions .functiondesc {font-size: 90%;} \ No newline at end of file +#page-admin-webservice-service_functions .functiondesc {font-size: 90%;} \ No newline at end of file diff --git a/theme/standard/style/admin.css b/theme/standard/style/admin.css index 0d81c2e9d77..f5601c57ca7 100644 --- a/theme/standard/style/admin.css +++ b/theme/standard/style/admin.css @@ -150,4 +150,4 @@ table.flexible .r1 {background-color: #FAFAFA;} */ #page-admin-webservice-service_users .missingcaps {color: #ff6600;font-size: 90%;} #page-admin-setting-webservicetokens .missingcaps {color: #ff6600;font-size: 90%;} -#page-admin-websevice-service_functions .functiondesc {font-size: 90%;} \ No newline at end of file +#page-admin-webservice-service_functions .functiondesc {font-size: 90%;} \ No newline at end of file diff --git a/webservice/renderer.php b/webservice/renderer.php index a78706dd2cf..3acd0761e37 100644 --- a/webservice/renderer.php +++ b/webservice/renderer.php @@ -143,49 +143,54 @@ class core_webservice_renderer extends plugin_renderer_base { * @return string the table html + add operation html */ public function admin_service_function_list($functions, $service) { - $table = new html_table(); - $table->head = array(get_string('function', 'webservice'), - get_string('description'), get_string('requiredcaps', 'webservice')); - $table->align = array('left', 'left', 'left'); - $table->size = array('15%', '40%', '40%'); - $table->width = '100%'; - $table->align[] = 'left'; + if (!empty($functions)) { + $table = new html_table(); + $table->head = array(get_string('function', 'webservice'), + get_string('description'), get_string('requiredcaps', 'webservice')); + $table->align = array('left', 'left', 'left'); + $table->size = array('15%', '40%', '40%'); + $table->width = '100%'; + $table->align[] = 'left'; - //display remove function operation (except for build-in service) - if (empty($service->component)) { - $table->head[] = get_string('edit'); - $table->align[] = 'center'; - } - - foreach ($functions as $function) { - $function = external_function_info($function); - $requiredcaps = html_writer::tag('div', - empty($function->capabilities)?'':$function->capabilities, - array('class' => 'functiondesc'));; - $description = html_writer::tag('div', $function->description, - array('class' => 'functiondesc')); //display remove function operation (except for build-in service) if (empty($service->component)) { - $removeurl = new moodle_url('/admin/webservice/service_functions.php', - array('sesskey' => sesskey(), 'fid' => $function->id, - 'id' => $service->id, - 'action' => 'delete')); - $removelink = html_writer::tag('a', - get_string('removefunction', 'webservice'), - array('href' => $removeurl)); - $table->data[] = array($function->name, $description, $requiredcaps, $removelink); - } else { - $table->data[] = array($function->name, $description, $requiredcaps); + $table->head[] = get_string('edit'); + $table->align[] = 'center'; } - } - $html = html_writer::table($table); + foreach ($functions as $function) { + $function = external_function_info($function); + $requiredcaps = html_writer::tag('div', + empty($function->capabilities) ? '' : $function->capabilities, + array('class' => 'functiondesc')); + ; + $description = html_writer::tag('div', $function->description, + array('class' => 'functiondesc')); + //display remove function operation (except for build-in service) + if (empty($service->component)) { + $removeurl = new moodle_url('/admin/webservice/service_functions.php', + array('sesskey' => sesskey(), 'fid' => $function->id, + 'id' => $service->id, + 'action' => 'delete')); + $removelink = html_writer::tag('a', + get_string('removefunction', 'webservice'), + array('href' => $removeurl)); + $table->data[] = array($function->name, $description, $requiredcaps, $removelink); + } else { + $table->data[] = array($function->name, $description, $requiredcaps); + } + } + + $html = html_writer::table($table); + } else { + $html = get_string('nofunctions', 'webservice') . html_writer::empty_tag('br'); + } //display add function operation (except for build-in service) if (empty($service->component)) { $addurl = new moodle_url('/admin/webservice/service_functions.php', array('sesskey' => sesskey(), 'id' => $service->id, 'action' => 'add')); - $html .= html_writer::tag('a', get_string('add'), array('href' => $addurl)); + $html .= html_writer::tag('a', get_string('addfunctions', 'webservice'), array('href' => $addurl)); } return $html;