Пример #1
0
 /**
  * Build XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string XHTML
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     $output = "";
     //search all web service users
     $users = get_users(true, '', false, null, 'firstname ASC', '', '', '', 1000);
     $table = new html_table();
     $table->head = array('username', 'whitelist');
     $table->align = array('left', 'center');
     $table->data = array();
     foreach ($users as $user) {
         if (has_capability("moodle/site:usewebservices", get_system_context(), $user->id)) {
             //test if the users has has_capability('use_webservice')
             $wsusersetting = ' <a href="' . $this->baseurl . '&amp;username='******'">' . get_string("settings") . '</a>' . "\n";
             $field = html_field::make_text('whitelist_' . $user->username);
             $field->style = "width: {$size}px;";
             $textfield = $OUTPUT->textfield($field);
             $table->data[] = array($user->username, $wsusersetting);
         }
     }
     $output .= $OUTPUT->table($table);
     return highlight($query, $output);
 }
Пример #2
0
/**
 * Display an standard html text field with an optional label
 *
 * @deprecated since Moodle 2.0
 *
 * @param string $name    The name of the text field
 * @param string $value   The value of the text field
 * @param string $alt     The info to be inserted in the alt tag
 * @param int $size Sets the size attribute of the field. Defaults to 50
 * @param int $maxlength Sets the maxlength attribute of the field. Not set by default
 * @param bool $return Whether this function should return a string or output
 *                     it (defaults to false)
 * @return string|void If $return=true returns string, else echo's and returns void
 */
function print_textfield($name, $value, $alt = '', $size = 50, $maxlength = 0, $return = false)
{
    debugging('print_textfield() has been deprecated. Please change your code to use $OUTPUT->textfield($field).');
    global $OUTPUT;
    $field = html_field::make_text($name, $value, $alt, $maxlength);
    $field->style = "width: {$size}px;";
    $output = $OUTPUT->textfield($field);
    if (empty($return)) {
        echo $output;
    } else {
        return $output;
    }
}