示例#1
0
文件: index.php 项目: patkira/mahara
/**
 * Service Users edit form
 *
 * @return html
 */
function service_users_edit_form()
{
    global $THEME, $USER;
    $editicon = 'icon icon-pencil prm';
    $deleteicon = 'icon icon-trash prm text-danger';
    $form = array('name' => 'webservices_users', 'elementclasses' => false, 'successcallback' => 'webservices_users_submit', 'renderer' => 'multicolumntable', 'elements' => array('username' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('username', 'auth.webservice')), 'institution' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('institution')), 'servicename' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('servicename', 'auth.webservice')), 'enabled' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('enabled')), 'wssigenc' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('titlewssigenc', 'auth.webservice')), 'functions' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('functions', 'auth.webservice')), 'actions' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => '')));
    $dbusers = get_records_sql_array('SELECT eu.id as id, eu.userid as userid, eu.wssigenc AS wssigenc, eu.externalserviceid as externalserviceid, eu.institution as institution, u.username as username, es.name as name, es.enabled as enabled FROM {external_services_users} AS eu LEFT JOIN {usr} AS u ON eu.userid = u.id LEFT JOIN {external_services} AS es ON eu.externalserviceid = es.id ORDER BY eu.id', array());
    if (!empty($dbusers)) {
        foreach ($dbusers as $user) {
            $dbinstitution = get_record('institution', 'name', $user->institution);
            if ($USER->is_admin_for_user($user->id)) {
                $user_url = get_config('wwwroot') . 'admin/users/edit.php?id=' . $user->userid;
            } else {
                $user_url = get_config('wwwroot') . 'user/view.php?id=' . $user->userid;
            }
            $form['elements']['id' . $user->id . '_username'] = array('value' => '<a href="' . $user_url . '">' . $user->username . '</a>', 'type' => 'html', 'key' => $user->id);
            $form['elements']['id' . $user->id . '_institution'] = array('value' => $dbinstitution->displayname, 'type' => 'html', 'key' => $user->id);
            $form['elements']['id' . $user->id . '_servicename'] = array('value' => $user->name, 'type' => 'html', 'key' => $user->id);
            $form['elements']['id' . $user->id . '_enabled'] = array('value' => $user->enabled == 1 ? display_icon('enabled') : display_icon('disabled'), 'type' => 'html', 'class' => 'center', 'key' => $user->id);
            $form['elements']['id' . $user->id . '_wssigenc'] = array('value' => $user->wssigenc == 1 ? display_icon('enabled') : display_icon('disabled'), 'type' => 'html', 'class' => 'center', 'key' => $user->id);
            $functions = get_records_array('external_services_functions', 'externalserviceid', $user->externalserviceid);
            $function_list = array();
            if ($functions) {
                foreach ($functions as $function) {
                    $dbfunction = get_record('external_functions', 'name', $function->functionname);
                    $function_list[] = '<a href="' . get_config('wwwroot') . 'webservice/wsdoc.php?id=' . $dbfunction->id . '">' . $function->functionname . '</a>';
                }
            }
            $form['elements']['id' . $user->id . '_functions'] = array('value' => implode(', ', $function_list), 'type' => 'html', 'key' => $user->id);
            // edit and delete buttons
            $form['elements']['id' . $user->id . '_actions'] = array('value' => pieform(array('name' => 'webservices_user_edit_' . $user->id, 'renderer' => 'div', 'elementclasses' => false, 'successcallback' => 'webservices_user_submit', 'class' => 'form-as-button pull-left', 'jsform' => false, 'elements' => array('suid' => array('type' => 'hidden', 'value' => $user->id), 'action' => array('type' => 'hidden', 'value' => 'edit'), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-default btn-sm', 'value' => '<span class="' . $editicon . '"></span>' . get_string('edit'), 'elementtitle' => get_string('editspecific', 'mahara', $user->username))))) . pieform(array('name' => 'webservices_user_delete_' . $user->id, 'renderer' => 'div', 'elementclasses' => false, 'successcallback' => 'webservices_user_submit', 'class' => 'form-as-button pull-left', 'jsform' => false, 'elements' => array('suid' => array('type' => 'hidden', 'value' => $user->id), 'action' => array('type' => 'hidden', 'value' => 'delete'), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-default btn-sm', 'value' => '<span class="' . $deleteicon . '"></span>' . get_string('delete'), 'elementtitle' => get_string('deletespecific', 'mahara', $user->username))))), 'type' => 'html', 'key' => $user->id, 'class' => 'webserviceconfigcontrols btn-group');
        }
    } else {
        // no results so hide headings
        $form['elements'] = array();
    }
    $username = '';
    if ($user = param_integer('user', 0)) {
        $dbuser = get_record('usr', 'id', $user);
        if (!empty($dbuser)) {
            $username = $dbuser->username;
        }
    } else {
        $username = param_alphanum('username', '');
    }
    $pieform = new pieform($form);
    return $pieform->build(false) . '<div id="user_add">' . pieform(array('name' => 'webservices_user_generate', 'renderer' => 'div', 'successcallback' => 'webservices_user_submit', 'jsform' => false, 'action' => get_config('wwwroot') . 'webservice/admin/index.php', 'elements' => array('userid' => array('type' => 'autocomplete', 'title' => get_string('username') . ': ', 'ajaxurl' => get_config('wwwroot') . 'webservice/admin/users.json.php', 'multiple' => true, 'allowclear' => true, 'ajaxextraparams' => array(), 'extraparams' => array('maximumSelectionLength' => 1), 'width' => '280px'), 'action' => array('type' => 'hidden', 'value' => 'add'), 'submit' => array('type' => 'submit', 'class' => 'submit btn-primary last', 'value' => get_string('add'))))) . '</div>';
}
示例#2
0
        $dbservice->validuntil = $dbtoken->validuntil;
    } else {
        $dbservice->validuntil = 0;
    }
}
/*
 * display the access tokens for services
 */
$userform = get_string('notokens', 'auth.webservice');
if (!empty($dbservices)) {
    $userform = array('name' => 'webservices_user_tokens', 'elementclasses' => false, 'successcallback' => 'webservices_user_tokens_submit', 'renderer' => 'multicolumntable', 'elements' => array('service_name' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('serviceaccess', 'auth.webservice')), 'enabled' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('enabled')), 'token' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('token', 'auth.webservice')), 'functions' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('functions', 'auth.webservice')), 'last_access' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('last_access', 'auth.webservice')), 'expires' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => get_string('expires', 'auth.webservice')), 'actions' => array('title' => ' ', 'datatable' => true, 'type' => 'html', 'value' => '')));
    foreach ($dbservices as $service) {
        // name of the service group
        $userform['elements']['id' . $service->id . '_service_name'] = array('value' => $service->name, 'type' => 'html', 'key' => $service->id);
        // is the service group enabled
        $userform['elements']['id' . $service->id . '_enabled'] = array('value' => $service->enabled == 1 ? display_icon('enabled') : display_icon('disabled'), 'type' => 'html', 'class' => 'text-center', 'key' => $service->id);
        // token for the service if it exists
        $userform['elements']['id' . $service->id . '_token'] = array('value' => empty($service->token) ? get_string('no_token', 'auth.webservice') : $service->token, 'type' => 'html', 'key' => $service->id);
        // list of functions that are available in the service group
        $functions = get_records_array('external_services_functions', 'externalserviceid', $service->id);
        $function_list = array();
        if ($functions) {
            foreach ($functions as $function) {
                $dbfunction = get_record('external_functions', 'name', $function->functionname);
                $function_list[] = '<a href="' . get_config('wwwroot') . 'webservice/wsdoc.php?id=' . $dbfunction->id . '">' . $function->functionname . '</a>';
            }
        }
        $userform['elements']['id' . $service->id . '_functions'] = array('value' => implode(', ', $function_list), 'type' => 'html', 'key' => $service->id);
        // last time the token was accessed if there is a token
        $userform['elements']['id' . $service->id . '_last_access'] = array('value' => empty($service->mtime) ? ' ' : format_date(strtotime($service->mtime)), 'type' => 'html', 'key' => $service->id);
        // expiry date for the token if it exists
示例#3
0
function webservice_server_list_form($sopts, $iopts)
{
    global $USER, $THEME;
    $dbconsumers = get_records_sql_assoc('
            SELECT  osr.id              as id,
                    userid              as userid,
                    institution         as institution,
                    externalserviceid   as externalserviceid,
                    u.username          as username,
                    u.email             as email,
                    consumer_key        as consumer_key,
                    consumer_secret     as consumer_secret,
                    enabled             as enabled,
                    status              as status,
                    osr.ctime           as issue_date,
                    application_uri     as application_uri,
                    application_title   as application_title,
                    application_descr   as application_descr,
                    requester_name      as requester_name,
                    requester_email     as requester_email,
                    callback_uri        as callback_uri
            FROM {oauth_server_registry} osr
            JOIN {usr} u
            ON osr.userid = u.id
            ORDER BY application_title, username
            ', array());
    $form = '';
    if (!empty($dbconsumers)) {
        $form = array('name' => 'webservices_tokens', 'elementclasses' => false, 'successcallback' => 'webservices_tokens_submit', 'renderer' => 'multicolumntable', 'elements' => array('application' => array('title' => ' ', 'class' => 'heading', 'type' => 'html', 'value' => get_string('application', 'auth.webservice')), 'username' => array('title' => ' ', 'type' => 'html', 'value' => get_string('owner', 'auth.webservice')), 'consumer_key' => array('title' => ' ', 'type' => 'html', 'value' => get_string('consumer_key', 'auth.webservice')), 'consumer_secret' => array('title' => ' ', 'type' => 'html', 'value' => get_string('consumer_secret', 'auth.webservice')), 'enabled' => array('title' => ' ', 'type' => 'html', 'value' => get_string('enabled')), 'calback_uri' => array('title' => ' ', 'type' => 'html', 'value' => get_string('callback', 'auth.webservice')), 'consumer_secret' => array('title' => ' ', 'type' => 'html', 'value' => get_string('consumer_secret', 'auth.webservice'))));
        foreach ($dbconsumers as $consumer) {
            $form['elements']['id' . $consumer->id . '_application'] = array('value' => $consumer->application_title, 'type' => 'html', 'key' => $consumer->consumer_key);
            if ($USER->is_admin_for_user($consumer->userid)) {
                $user_url = get_config('wwwroot') . 'admin/users/edit.php?id=' . $consumer->userid;
            } else {
                $user_url = get_config('wwwroot') . 'user/view.php?id=' . $consumer->userid;
            }
            $form['elements']['id' . $consumer->id . '_username'] = array('value' => '<a href="' . $user_url . '">' . $consumer->username . '</a>', 'type' => 'html', 'key' => $consumer->consumer_key);
            $form['elements']['id' . $consumer->id . '_consumer_key'] = array('value' => $consumer->consumer_key, 'type' => 'html', 'key' => $consumer->consumer_key);
            $form['elements']['id' . $consumer->id . '_consumer_secret'] = array('value' => $consumer->consumer_secret, 'type' => 'html', 'key' => $consumer->consumer_key);
            $form['elements']['id' . $consumer->id . '_enabled'] = array('value' => $consumer->enabled == 1 ? display_icon('enabled') : display_icon('disabled'), 'type' => 'html', 'class' => 'center', 'key' => $consumer->consumer_key);
            $form['elements']['id' . $consumer->id . '_calback_uri'] = array('value' => $consumer->callback_uri, 'type' => 'html', 'key' => $consumer->consumer_key);
            // edit and delete buttons
            $form['elements']['id' . $consumer->id . '_actions'] = array('value' => '<span class="actions inline">' . pieform(array('name' => 'webservices_server_edit_' . $consumer->id, 'renderer' => 'div', 'elementclasses' => false, 'successcallback' => 'webservices_server_submit', 'jsform' => false, 'elements' => array('token' => array('type' => 'hidden', 'value' => $consumer->id), 'action' => array('type' => 'hidden', 'value' => 'edit'), 'submit' => array('type' => 'image', 'src' => $THEME->get_url('images/btn_edit.png'), 'alt' => get_string('editspecific', 'mahara', $consumer->id), 'elementtitle' => get_string('edit'))))) . pieform(array('name' => 'webservices_server_delete_' . $consumer->id, 'renderer' => 'div', 'elementclasses' => false, 'successcallback' => 'webservices_server_submit', 'jsform' => false, 'elements' => array('token' => array('type' => 'hidden', 'value' => $consumer->id), 'action' => array('type' => 'hidden', 'value' => 'delete'), 'submit' => array('type' => 'image', 'src' => $THEME->get_url('images/btn_deleteremove.png'), 'alt' => get_string('deletespecific', 'mahara', $consumer->id), 'elementtitle' => get_string('delete'))))) . '</span>', 'type' => 'html', 'key' => $consumer->consumer_key, 'class' => 'webserviceconfigcontrols');
        }
        $pieform = new Pieform($form);
        $form = $pieform->build(false);
    }
    $form = '<tr><td colspan="2">' . $form . '</td></tr><tr><td colspan="2">' . pieform(array('name' => 'webservices_token_generate', 'renderer' => 'div', 'validatecallback' => 'webservices_add_application_validate', 'successcallback' => 'webservices_add_application_submit', 'class' => 'oneline inline', 'jsform' => false, 'action' => get_config('wwwroot') . 'webservice/admin/oauthv1sregister.php', 'elements' => array('application' => array('type' => 'text', 'title' => get_string('application', 'auth.webservice') . ': '), 'institution' => array('type' => 'select', 'options' => $iopts), 'service' => array('type' => 'select', 'options' => $sopts), 'action' => array('type' => 'hidden', 'value' => 'add'), 'submit' => array('type' => 'submit', 'value' => get_string('add', 'auth.webservice'))))) . '</td></tr>';
    $elements = array('register_server' => array('type' => 'fieldset', 'legend' => get_string('userapplications', 'auth.webservice'), 'elements' => array('sflist' => array('type' => 'html', 'value' => $form)), 'collapsible' => false));
    $form = array('renderer' => 'table', 'type' => 'div', 'id' => 'maintable', 'name' => 'maincontainer', 'dieaftersubmit' => false, 'successcallback' => 'webservice_main_submit', 'elements' => $elements);
    return $form;
}
示例#4
0
"><?php 
        $id2val = "";
        $dependency = "";
        display_word_info($w, $editor);
        display_definitions($w, $editor);
        if ($inflection) {
            display_inflection($w);
        }
        if ($editor) {
            ?>
<div id="word<?php 
            echo $id;
            ?>
_edit_button"><br>
				<?php 
            display_icon("edit", "Edit");
            ?>
				</div>
				<div id="word<?php 
            echo $id;
            ?>
_edit"><?php 
            $_level = array_merge($w->mgr()->simple_keys, $w->mgr()->recursive_keys);
            foreach ($w->mgr()->all_sub_keys as $k) {
                $first_level = in_array($k, $_level);
                $isselector = in_array($k, $w->mgr()->recursive_keys);
                if ($isselector) {
                    $dependency .= "'{$k}':{";
                    $depaths = $w->mgr()->level[$k];
                    foreach ($depaths as $_k => $depath) {
                        $dependency .= "'{$_k}':{";
示例#5
0
function display_inflection($w, $hidden = TRUE)
{
    if ($c = $w->cached()) {
        if (($_ = json_decode($c, true)) === NULL) {
            echo $c;
            return;
        } else {
            $c = $_;
        }
        for ($i = 0; $i < count($c); $i++) {
            if ($i === 0) {
                echo $c[$i];
            } else {
                echo format_word($c[$i]);
            }
        }
        return;
    } else {
        ob_start();
    }
    $pronunciations = $w->pronunciations();
    //error_log($pronunciations);
    $w->clear_connections();
    $connections = $w->connections();
    list($values0, $values1, $values2, $values3, $values4) = word_table_values($w);
    if (!$values0 and !$values1 and !$values3 and !$values4 and !$values2) {
        ?>
<span id="word<?php 
        echo $w->id();
        ?>
_forms">(No inflection for this word)</span><?php 
        return;
    }
    ?>
	Inflection
	<?php 
    display_icon("visibility", $hidden ? "Show" : "Hide", "toggle-forms" . $w->id());
    if ($pronunciations) {
        ?>
<span id="toggle-pronunciations<?php 
        echo $w->id();
        ?>
_outer">
			[<a href="javascript:void(0)" id="toggle-pronunciations<?php 
        echo $w->id();
        ?>
">show IPA</a>]<br><br>
		</span><?php 
    }
    ?>
<span id="toggle-quizzing<?php 
    echo $w->id();
    ?>
_outer">
		[<a href="javascript:void(0)" id="toggle-quizzing<?php 
    echo $w->id();
    ?>
">cover forms</a>]<br><br>
	</span><?php 
    do_table($w, $values0, $values1, $values2, $values3, $values4, NULL, "format_value", function ($v, $p) use($w) {
        return format_word($p, $w->lang(), true);
    }, function ($p) use($connections) {
        $p = (string) $p;
        foreach ($connections as $connect) {
            if ($connect->type() === $p) {
                return $connect->to();
            }
        }
    }, function ($p) use($pronunciations, $w) {
        $p = (string) $p;
        $made_div = FALSE;
        $last_type = NULL;
        $first = TRUE;
        foreach ($pronunciations as $pron) {
            if ((string) $pron->path() !== $p) {
                continue;
            }
            if ($pron->type() !== "IPA") {
                continue;
            }
            if (!$made_div) {
                ?>
<span class="word<?php 
                echo $w->id();
                ?>
_pronunciation"><?php 
                $made_div = TRUE;
            }
            ?>
<br><?php 
            $last_type = $pron->type();
            if ($pron->sublang()) {
                ?>
<sup>[<?php 
                echo $pron->sublang();
                ?>
]</sup><?php 
            }
            ?>
[<?php 
            echo format_pron($pron->value());
            ?>
]<?php 
            $first = FALSE;
        }
        if ($made_div) {
            ?>
</span><?php 
        }
    });
    ?>
	<script type="text/javascript">
		$(function(){
			var c = "<?php 
    echo $w->id();
    ?>
";
			var selector = $('#word'+c+'_forms, #toggle-pronunciations'+c+'_outer, #toggle-quizzing'+c+'_outer');
			$('#toggle-forms'+c).click(function () {
				selector.toggle();
				var vis = $('#word'+c+'_forms').is(':visible');
				$('#toggle-forms'+c).attr('title', vis ? 'Hide' : 'Show');
				if (!vis)
					$('.word'+c+'_pronunciation').hide();
			});
		<?php 
    if (!$hidden) {
        ?>
			selector.hide();
		<?php 
    }
    ?>
			$('#toggle-forms'+c).trigger("click");
			$('#toggle-pronunciations'+c).click(function () {
				$('.word'+c+'_pronunciation').toggle();
				$('#toggle-pronunciations'+c).attr('title', $('.word'+c+'_pronunciation').is(':visible') ? 'hide IPA' : 'show IPA');
			});
			$('#toggle-quizzing'+c).click(function () {
				$('#word'+c+' td').addClass('hidden').on('click', function() {$(this).removeClass('hidden').off('click')});
			});
			$('.word'+c+'_pronunciation, #toggle-pronunciations').hide();
		});
	</script>
	<?php 
    $w->set_cached(ob_get_contents());
    ob_end_flush();
}
示例#6
0
?>
			<?php 
display_icon("&lt;", "Previous", "goto-prev");
?>
			<input placeholder="<?php 
echo $start;
?>
" type="number" value="<?php 
echo $start;
?>
" min="0" id="start-at" style="width: 80px;">
			<?php 
display_icon("&gt;", "Next", "goto-next");
?>
			<?php 
display_icon("&gt;&gt;", "Last", "goto-last");
?>
		<script>
			$('#start-at').on("keypress", function(event) {
				if (event.which == 13) {
					$(this).blur();
					dict.refreshEntries();
				}
			});
			$('#start-at').on("change", function(event) {
				$(this).blur();
				dict.refreshEntries();
			});
			$('#goto-first').on('click', function() {
				$('#start-at').val(0);
				dict.refreshEntries();