Esempio n. 1
0
/**
 * Returns the list of all editing actions that current user can perform on the module
 *
 * @param cm_info $mod The module to produce editing buttons for
 * @param int $indent The current indenting (default -1 means no move left-right actions)
 * @param int $sr The section to link back to (used for creating the links)
 * @return array array of action_link or pix_icon objects
 */
function course_get_cm_edit_actions_reduced(cm_info $mod, $indent = -1, $sr = null)
{
    global $COURSE, $SITE;
    static $str;
    $coursecontext = context_course::instance($mod->course);
    $modcontext = context_module::instance($mod->id);
    $editcaps = array('moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/role:assign');
    $dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
    //No permission to edit anything.
    if (!has_any_capability($editcaps, $modcontext) and !has_all_capabilities($dupecaps, $coursecontext)) {
        return array();
    }
    $hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
    if (!isset($str)) {
        $str = get_strings(array('delete', 'move', 'moveright', 'moveleft', 'editsettings', 'duplicate', 'hide', 'show'), 'moodle');
        $str->assign = get_string('assignroles', 'role');
        $str->groupsnone = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsnone"));
        $str->groupsseparate = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsseparate"));
        $str->groupsvisible = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsvisible"));
    }
    $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
    if ($sr !== null) {
        $baseurl->param('sr', $sr);
    }
    $actions = array();
    // Duplicate (require both target import caps to be able to duplicate and backup2 support, see modduplicate.php)
    // Note that restoring on front page is never allowed.
    if ($mod->course != SITEID && has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2)) {
        $actions['duplicate'] = new action_menu_link_secondary(new moodle_url($baseurl, array('duplicate' => $mod->id)), new pix_icon('t/copy', $str->duplicate, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->duplicate, array('class' => 'editing_duplicate', 'data-action' => 'duplicate', 'data-sr' => $sr));
    }
    // Delete.
    if ($hasmanageactivities) {
        $actions['delete'] = new action_menu_link_secondary(new moodle_url($baseurl, array('delete' => $mod->id)), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->delete, array('class' => 'editing_delete', 'data-action' => 'delete'));
    }
    return $actions;
}
Esempio n. 2
0
 function output_html($data, $query = '')
 {
     global $CFG;
     // display strings
     $txt = get_strings(array('authenticationplugins', 'users', 'administration', 'settings', 'edit', 'name', 'enable', 'disable', 'up', 'down', 'none'));
     $txt->updown = "{$txt->up}/{$txt->down}";
     $authsavailable = get_list_of_plugins('auth');
     get_enabled_auth_plugins(true);
     // fix the list of enabled auths
     if (empty($CFG->auth)) {
         $authsenabled = array();
     } else {
         $authsenabled = explode(',', $CFG->auth);
     }
     // construct the display array, with enabled auth plugins at the top, in order
     $displayauths = array();
     $registrationauths = array();
     $registrationauths[''] = $txt->disable;
     foreach ($authsenabled as $auth) {
         $authplugin = get_auth_plugin($auth);
         /// Get the auth title (from core or own auth lang files)
         $authtitle = get_string("auth_{$auth}title", "auth");
         if ($authtitle == "[[auth_{$auth}title]]") {
             $authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
         }
         /// Apply titles
         $displayauths[$auth] = $authtitle;
         if ($authplugin->can_signup()) {
             $registrationauths[$auth] = $authtitle;
         }
     }
     foreach ($authsavailable as $auth) {
         if (array_key_exists($auth, $displayauths)) {
             continue;
             //already in the list
         }
         $authplugin = get_auth_plugin($auth);
         /// Get the auth title (from core or own auth lang files)
         $authtitle = get_string("auth_{$auth}title", "auth");
         if ($authtitle == "[[auth_{$auth}title]]") {
             $authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
         }
         /// Apply titles
         $displayauths[$auth] = $authtitle;
         if ($authplugin->can_signup()) {
             $registrationauths[$auth] = $authtitle;
         }
     }
     $return = print_heading(get_string('actauthhdr', 'auth'), '', 3, 'main', true);
     $return .= print_box_start('generalbox authsui', '', true);
     $table = new object();
     $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings);
     $table->align = array('left', 'center', 'center', 'center');
     $table->width = '90%';
     $table->data = array();
     //add always enabled plugins first
     $displayname = "<span>" . $displayauths['manual'] . "</span>";
     $settings = "<a href=\"auth_config.php?auth=manual\">{$txt->settings}</a>";
     //$settings = "<a href=\"settings.php?section=authsettingmanual\">{$txt->settings}</a>";
     $table->data[] = array($displayname, '', '', $settings);
     $displayname = "<span>" . $displayauths['nologin'] . "</span>";
     $settings = "<a href=\"auth_config.php?auth=nologin\">{$txt->settings}</a>";
     $table->data[] = array($displayname, '', '', $settings);
     // iterate through auth plugins and add to the display table
     $updowncount = 1;
     $authcount = count($authsenabled);
     $url = "auth.php?sesskey=" . sesskey();
     foreach ($displayauths as $auth => $name) {
         if ($auth == 'manual' or $auth == 'nologin') {
             continue;
         }
         // hide/show link
         if (in_array($auth, $authsenabled)) {
             $hideshow = "<a href=\"{$url}&amp;action=disable&amp;auth={$auth}\">";
             $hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" /></a>";
             // $hideshow = "<a href=\"$url&amp;action=disable&amp;auth=$auth\"><input type=\"checkbox\" checked /></a>";
             $enabled = true;
             $displayname = "<span>{$name}</span>";
         } else {
             $hideshow = "<a href=\"{$url}&amp;action=enable&amp;auth={$auth}\">";
             $hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" /></a>";
             // $hideshow = "<a href=\"$url&amp;action=enable&amp;auth=$auth\"><input type=\"checkbox\" /></a>";
             $enabled = false;
             $displayname = "<span class=\"dimmed_text\">{$name}</span>";
         }
         // up/down link (only if auth is enabled)
         $updown = '';
         if ($enabled) {
             if ($updowncount > 1) {
                 $updown .= "<a href=\"{$url}&amp;action=up&amp;auth={$auth}\">";
                 $updown .= "<img src=\"{$CFG->pixpath}/t/up.gif\" alt=\"up\" /></a>&nbsp;";
             } else {
                 $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />&nbsp;";
             }
             if ($updowncount < $authcount) {
                 $updown .= "<a href=\"{$url}&amp;action=down&amp;auth={$auth}\">";
                 $updown .= "<img src=\"{$CFG->pixpath}/t/down.gif\" alt=\"down\" /></a>";
             } else {
                 $updown .= "<img src=\"{$CFG->pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />";
             }
             ++$updowncount;
         }
         // settings link
         if (file_exists($CFG->dirroot . '/auth/' . $auth . '/settings.php')) {
             $settings = "<a href=\"settings.php?section=authsetting{$auth}\">{$txt->settings}</a>";
         } else {
             $settings = "<a href=\"auth_config.php?auth={$auth}\">{$txt->settings}</a>";
         }
         // add a row to the table
         $table->data[] = array($displayname, $hideshow, $updown, $settings);
     }
     $return .= print_table($table, true);
     $return .= get_string('configauthenticationplugins', 'admin') . '<br />' . get_string('tablenosave', 'filters');
     $return .= print_box_end(true);
     return highlight($query, $return);
 }
Esempio n. 3
0
/**
 * Returns the list of all editing actions that current user can perform on the module
 *
 * @param cm_info $mod The module to produce editing buttons for
 * @param int $indent The current indenting (default -1 means no move left-right actions)
 * @param int $sr The section to link back to (used for creating the links)
 * @return array array of action_link or pix_icon objects
 */
function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null)
{
    global $COURSE, $SITE;
    static $str;
    $coursecontext = context_course::instance($mod->course);
    $modcontext = context_module::instance($mod->id);
    $editcaps = array('moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/role:assign');
    $dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
    // no permission to edit anything
    if (!has_any_capability($editcaps, $modcontext) and !has_all_capabilities($dupecaps, $coursecontext)) {
        return array();
    }
    $hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
    if (!isset($str)) {
        $str = get_strings(array('delete', 'move', 'moveright', 'moveleft', 'update', 'duplicate', 'hide', 'show', 'edittitle'), 'moodle');
        $str->assign = get_string('assignroles', 'role');
        $str->groupsnone = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsnone"));
        $str->groupsseparate = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsseparate"));
        $str->groupsvisible = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsvisible"));
        $str->forcedgroupsnone = get_string('forcedmodeinbrackets', 'moodle', get_string("groupsnone"));
        $str->forcedgroupsseparate = get_string('forcedmodeinbrackets', 'moodle', get_string("groupsseparate"));
        $str->forcedgroupsvisible = get_string('forcedmodeinbrackets', 'moodle', get_string("groupsvisible"));
    }
    $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
    if ($sr !== null) {
        $baseurl->param('sr', $sr);
    }
    $actions = array();
    // AJAX edit title
    if ($mod->has_view() && $hasmanageactivities && ($mod->course == $COURSE->id && course_ajax_enabled($COURSE) || $mod->course == SITEID && course_ajax_enabled($SITE))) {
        // we will not display link if we are on some other-course page (where we should not see this module anyway)
        $actions['title'] = new action_link(new moodle_url($baseurl, array('update' => $mod->id)), new pix_icon('t/editstring', $str->edittitle, 'moodle', array('class' => 'iconsmall visibleifjs', 'title' => '')), null, array('class' => 'editing_title', 'title' => $str->edittitle));
    }
    // leftright
    if ($hasmanageactivities) {
        if (right_to_left()) {
            // Exchange arrows on RTL
            $rightarrow = 't/left';
            $leftarrow = 't/right';
        } else {
            $rightarrow = 't/right';
            $leftarrow = 't/left';
        }
        if ($indent > 0) {
            $actions['moveleft'] = new action_link(new moodle_url($baseurl, array('id' => $mod->id, 'indent' => '-1')), new pix_icon($leftarrow, $str->moveleft, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_moveleft', 'title' => $str->moveleft));
        }
        if ($indent >= 0) {
            $actions['moveright'] = new action_link(new moodle_url($baseurl, array('id' => $mod->id, 'indent' => '1')), new pix_icon($rightarrow, $str->moveright, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_moveright', 'title' => $str->moveright));
        }
    }
    // move
    if ($hasmanageactivities) {
        $actions['move'] = new action_link(new moodle_url($baseurl, array('copy' => $mod->id)), new pix_icon('t/move', $str->move, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_move', 'title' => $str->move));
    }
    // Update
    if ($hasmanageactivities) {
        $actions['update'] = new action_link(new moodle_url($baseurl, array('update' => $mod->id)), new pix_icon('t/edit', $str->update, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_update', 'title' => $str->update));
    }
    // Duplicate (require both target import caps to be able to duplicate and backup2 support, see modduplicate.php)
    // note that restoring on front page is never allowed
    if ($mod->course != SITEID && has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2)) {
        $actions['duplicate'] = new action_link(new moodle_url($baseurl, array('duplicate' => $mod->id)), new pix_icon('t/copy', $str->duplicate, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_duplicate', 'title' => $str->duplicate));
    }
    // Delete
    if ($hasmanageactivities) {
        $actions['delete'] = new action_link(new moodle_url($baseurl, array('delete' => $mod->id)), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_delete', 'title' => $str->delete));
    }
    // hideshow
    if (has_capability('moodle/course:activityvisibility', $modcontext)) {
        if ($mod->visible) {
            $actions['hide'] = new action_link(new moodle_url($baseurl, array('hide' => $mod->id)), new pix_icon('t/hide', $str->hide, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_hide', 'title' => $str->hide));
        } else {
            $actions['show'] = new action_link(new moodle_url($baseurl, array('show' => $mod->id)), new pix_icon('t/show', $str->show, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_show', 'title' => $str->show));
        }
    }
    // groupmode
    if ($hasmanageactivities and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
        if ($mod->coursegroupmodeforce) {
            $modgroupmode = $mod->coursegroupmode;
        } else {
            $modgroupmode = $mod->groupmode;
        }
        if ($modgroupmode == SEPARATEGROUPS) {
            $groupmode = NOGROUPS;
            $grouptitle = $str->groupsseparate;
            $forcedgrouptitle = $str->forcedgroupsseparate;
            $actionname = 'groupsseparate';
            $groupimage = 't/groups';
        } else {
            if ($modgroupmode == VISIBLEGROUPS) {
                $groupmode = SEPARATEGROUPS;
                $grouptitle = $str->groupsvisible;
                $forcedgrouptitle = $str->forcedgroupsvisible;
                $actionname = 'groupsvisible';
                $groupimage = 't/groupv';
            } else {
                $groupmode = VISIBLEGROUPS;
                $grouptitle = $str->groupsnone;
                $forcedgrouptitle = $str->forcedgroupsnone;
                $actionname = 'groupsnone';
                $groupimage = 't/groupn';
            }
        }
        if (!$mod->coursegroupmodeforce) {
            $actions[$actionname] = new action_link(new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $groupmode)), new pix_icon($groupimage, $grouptitle, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_' . $actionname, 'title' => $grouptitle));
        } else {
            $actions[$actionname] = new pix_icon($groupimage, $forcedgrouptitle, 'moodle', array('title' => $forcedgrouptitle, 'class' => 'iconsmall'));
        }
    }
    // Assign
    if (has_capability('moodle/role:assign', $modcontext)) {
        $actions['assign'] = new action_link(new moodle_url('/admin/roles/assign.php', array('contextid' => $modcontext->id)), new pix_icon('t/assignroles', $str->assign, 'moodle', array('class' => 'iconsmall', 'title' => '')), null, array('class' => 'editing_assign', 'title' => $str->assign));
    }
    return $actions;
}
Esempio n. 4
0
function upload_strings($api_key, $secret, $input)
{
    $strings = get_strings($input);
    print_strings($strings);
    $cnt = count($strings);
    if ($cnt < 1) {
        echo "No strings found. Exiting.\n";
        exit;
    }
    echo "\nThe {$cnt} string(s) above will be uploaded.\n";
    echo "To exit now, use Ctrl-C.\n";
    $facebook = new FacebookDesktop($api_key, $secret);
    $auth_token = $facebook->api_client->auth_createToken();
    $login_url = build_url($api_key, $auth_token);
    `open "{$login_url}"`;
    do {
        echo "Otherwise, type 'y' to continue after logging into Facebook.\n";
    } while (!(strtolower(fgets(STDIN)) === "y\n"));
    if (null == $facebook->do_get_session($auth_token)) {
        echo "Could not obtain Facebook session. Exiting.\n";
        exit;
    }
    $unescaped_strings = unescape_c_strings($strings);
    $num_strings = $facebook->api_client->intl_uploadNativeStrings($unescaped_strings);
    if (!$num_strings) {
        echo "Oops. Sorry, failed to upload.\n";
    } else {
        echo "{$num_strings} string(s) uploaded successfully.\n";
    }
}
Esempio n. 5
0
    asort($frm->enable);
    $frm->enable = array_merge(array('manual'), $frm->enable);
    // make sure manual plugin is called first
    set_config('enrol_plugins_enabled', implode(',', $frm->enable));
    set_config('enrol', $frm->default);
    redirect("enrol.php", get_string("changessaved"), 1);
} else {
    if ($frm = data_submitted() and $savesettings) {
        if (!confirm_sesskey()) {
            print_error('confirmsesskeybad', 'error');
        }
        set_config('sendcoursewelcomemessage', required_param('sendcoursewelcomemessage', PARAM_BOOL));
    }
}
/// Print the form
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
admin_externalpage_print_header();
$modules = get_list_of_plugins("enrol");
$options = array();
foreach ($modules as $module) {
    $options[$module] = get_string("enrolname", "enrol_{$module}");
}
asort($options);
print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
echo "<form {$CFG->frametarget} id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
echo "<div>";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />";
$table = new stdClass();
$table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
$table->align = array('left', 'center', 'center', 'center');
$table->size = array('60%', '', '', '15%');
unset($exclude);
$searchtext = trim($searchtext);
if ($searchtext !== '') {
    // Search for a subset of remaining users
    $LIKE = sql_ilike();
    $FULLNAME = sql_fullname();
    $select .= " AND ({$FULLNAME} {$LIKE} '%{$searchtext}%' OR email {$LIKE} '%{$searchtext}%') ";
}
$sql = 'SELECT id, firstname, lastname, email 
            FROM ' . $CFG->prefix . 'user u
            WHERE deleted = 0 AND confirmed = 1 
                  AND mnethostid = ' . $CFG->mnet_localhost_id . ' ' . $select . 'ORDER BY lastname ASC, firstname ASC';
$availableusers = get_recordset_sql($sql, 0, MAX_USERS_PER_PAGE);
/// Print the page
/// get language strings
$str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
/// Get some language strings
$strpotentialusers = get_string('potentialusers', 'role');
$strexistingusers = get_string('existingusers', 'role');
$straction = get_string('assignroles', 'role');
$strroletoassign = get_string('roletoassign', 'role');
$strcurrentcontext = get_string('currentcontext', 'role');
$strsearch = get_string('search');
$strshowall = get_string('showall');
$strparticipants = get_string('participants');
$strsearchresults = get_string('searchresults');
admin_externalpage_print_header();
print_box('<strong>' . s($mnet_peer->name) . ' : ' . format_string($course->shortname) . ' ' . format_string($course->fullname) . '</strong><br />' . get_string("enrolcourseenrol_desc", "mnet"));
echo "<hr />";
include dirname(__FILE__) . '/enr_course_enrol.html';
if (!empty($errors)) {
Esempio n. 7
0
/**
 * Returns the rename action.
 *
 * @deprecated since 3.1
 * @param cm_info $mod The module to produce editing buttons for
 * @param int $sr The section to link back to (used for creating the links)
 * @return The markup for the rename action, or an empty string if not available.
 */
function course_get_cm_rename_action(cm_info $mod, $sr = null)
{
    global $COURSE, $OUTPUT;
    static $str;
    static $baseurl;
    debugging('Function course_get_cm_rename_action() is deprecated. Please use inplace_editable ' . 'https://docs.moodle.org/dev/Inplace_editable', DEBUG_DEVELOPER);
    $modcontext = context_module::instance($mod->id);
    $hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
    if (!isset($str)) {
        $str = get_strings(array('edittitle'));
    }
    if (!isset($baseurl)) {
        $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
    }
    if ($sr !== null) {
        $baseurl->param('sr', $sr);
    }
    // AJAX edit title.
    if ($mod->has_view() && $hasmanageactivities && course_ajax_enabled($COURSE) && ($mod->course == $COURSE->id || $mod->course == SITEID)) {
        // we will not display link if we are on some other-course page (where we should not see this module anyway)
        return html_writer::span(html_writer::link(new moodle_url($baseurl, array('update' => $mod->id)), $OUTPUT->pix_icon('t/editstring', '', 'moodle', array('class' => 'iconsmall visibleifjs', 'title' => '')), array('class' => 'editing_title', 'data-action' => 'edittitle', 'title' => $str->edittitle)));
    }
    return '';
}
Esempio n. 8
0
// $Id: index.php,v 2.9 2008/06/20 10:48:32 ethem Exp $
/// Load libraries
require_once '../../config.php';
require_once 'const.php';
require_once 'locallib.php';
require_once 'localfuncs.php';
require_once 'authorizenet.class.php';
/// Parameters
$orderid = optional_param('order', 0, PARAM_INT);
$courseid = optional_param('course', SITEID, PARAM_INT);
$userid = optional_param('user', 0, PARAM_INT);
/// Get course
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
    print_error('invalidcourseid', '', '', $courseid);
}
/// Only SITE users can access to this page
require_login();
// Don't use $courseid! User may want to see old orders.
if (has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) {
    print_error('noguest');
}
/// Load strings. All strings should be defined here. locallib.php uses these strings.
$strs = get_strings(array('search', 'status', 'action', 'time', 'course', 'confirm', 'yes', 'no', 'cancel', 'all', 'none', 'error'));
$authstrs = get_strings(array('orderid', 'nameoncard', 'echeckfirslasttname', 'void', 'capture', 'refund', 'delete', 'allpendingorders', 'authcaptured', 'authorizedpendingcapture', 'capturedpendingsettle', 'settled', 'refunded', 'cancelled', 'expired', 'underreview', 'approvedreview', 'reviewfailed', 'tested', 'new', 'paymentmethod', 'methodcc', 'methodecheck', 'paymentmanagement', 'orderdetails', 'cclastfour', 'isbusinesschecking', 'shopper', 'transid', 'settlementdate', 'notsettled', 'amount', 'unenrolstudent'), 'enrol_authorize');
/// User wants to see all orders
if (empty($orderid)) {
    authorize_print_orders($courseid, $userid);
} else {
    authorize_print_order($orderid);
}
Esempio n. 9
0
 *
 * Displays the list of found plagiarism plugins, their version (if found) and
 * a link to uninstall the plagiarism plugin.
 *
 * @see       http://docs.moodle.org/dev/Plagiarism_API
 * @package   admin
 * @copyright 2012 Dan Marsden <*****@*****.**>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(dirname(__FILE__)) . '/config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/tablelib.php';
admin_externalpage_setup('manageplagiarismplugins');
echo $OUTPUT->header();
// Print the table of all installed plagiarism plugins.
$txt = get_strings(array('settings', 'name', 'version'));
$txt->uninstall = get_string('uninstallplugin', 'core_admin');
$plagiarismplugins = core_component::get_plugin_list('plagiarism');
if (empty($plagiarismplugins)) {
    echo $OUTPUT->notification(get_string('nopluginsinstalled', 'plagiarism'));
    echo $OUTPUT->footer();
    exit;
}
echo $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main');
echo $OUTPUT->box_start('generalbox authsui');
$table = new html_table();
$table->head = array($txt->name, $txt->version, $txt->uninstall, $txt->settings);
$table->colclasses = array('mdl-left', 'mdl-align', 'mdl-align', 'mdl-align');
$table->data = array();
$table->attributes['class'] = 'manageplagiarismtable generaltable';
// Iterate through auth plugins and add to the display table.
Esempio n. 10
0
function theme_snap_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)
{
    global $PAGE;
    if ($PAGE->theme->name === 'snap') {
        if ($iscurrentuser) {
            $str = get_strings(['preferences']);
            if (isset($tree->nodes['editprofile'])) {
                $after = 'editprofile';
            } else {
                $after = null;
            }
            $url = new moodle_url('/user/preferences.php');
            $prefnode = new core_user\output\myprofile\node('contact', 'userpreferences', $str->preferences, $after, $url);
            $tree->add_node($prefnode);
        }
    }
}
Esempio n. 11
0
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

		<title><?php 
echo format_string($title);
?>
</title>

		<link rel="shortcut icon" href="pix/icon.ico"/>
		<script>
			var Elang = Elang || {};
			Elang.strings =
<?php 
include dirname(__FILE__) . '/lang/en/elang.php';
echo json_encode(get_strings(array_keys($string), 'elang'));
?>
;
		</script>
<?php 
if (file_exists(dirname(__FILE__) . '/build')) {
    ?>
		<link href="build/enyo.css" rel="stylesheet" />
		<link href="build/app.css" rel="stylesheet" />
		<script src="build/enyo.js"></script>
		<script src="build/app.js"></script>
<?php 
} else {
    ?>
		<script src="enyo/enyo.js" type="text/javascript"></script>
		<script src="source/package.js" type="text/javascript"></script>
 /**
  * Renders HTML to display one course module in a course section
  *
  * This includes link, content, availability, completion info and additional information
  * that module type wants to display (i.e. number of unread forum posts)
  *
  * This function calls:
  * {@link core_course_renderer::course_section_cm_name()}
  * {@link cm_info::get_after_link()}
  * {@link core_course_renderer::course_section_cm_text()}
  * {@link core_course_renderer::course_section_cm_availability()}
  * {@link core_course_renderer::course_section_cm_completion()}
  * {@link course_get_cm_edit_actions()}
  * {@link core_course_renderer::course_section_cm_edit_actions()}
  *
  * @param \stdClass $course
  * @param \completion_info $completioninfo
  * @param \cm_info $mod
  * @param int|null $sectionreturn
  * @param array $displayoptions
  * @return string
  */
 public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array())
 {
     global $COURSE;
     $output = '';
     // We return empty string (because course module will not be displayed at all)
     // if:
     // 1) The activity is not visible to users
     // and
     // 2) The 'availableinfo' is empty, i.e. the activity was
     // hidden in a way that leaves no info, such as using the
     // eye icon.
     if (!$mod->uservisible && empty($mod->availableinfo)) {
         return $output;
     }
     $output .= '<div class="asset-wrapper">';
     // TODO - add if can edit.
     // Drop section notice.
     $output .= '<a class="snap-move-note" href="#">' . get_string('movehere', 'theme_snap') . '</a>';
     // Start the div for the activity content.
     $output .= "<div class='activityinstance'>";
     // Display the link to the module (or do nothing if module has no url).
     $cmname = $this->course_section_cm_name($mod, $displayoptions);
     $assetlink = '';
     // SHAME - For moodles ajax show/hide call to work it needs activityinstance > a to add a class of dimmed to.
     // This dimmed class is of course inaccessible junk.
     if (!empty($cmname)) {
         $assetlink = '<a></a><h4 class="snap-asset-link">' . $cmname . '</h4>';
     }
     // Asset content.
     $contentpart = $this->course_section_cm_text($mod, $displayoptions);
     // Activity/resource type.
     $snapmodtype = $this->get_mod_type($mod)[0];
     $assetmeta = "<span class='snap-assettype'>" . $snapmodtype . "</span>";
     // Groups, Restriction and all that jazz metadata.
     // Completion tracking.
     $completiontracking = $this->course_section_cm_completion($course, $completioninfo, $mod, $displayoptions);
     // Due date, feedback available and all the nice snap things.
     $snapcompletiondata = $this->module_meta_html($mod);
     $assetcompletionmeta = "<div class='snap-completion-meta'>" . $completiontracking . $snapcompletiondata . "</div>";
     // Draft status - always output, shown via css of parent.
     $assetrestrictions = "<div class='draft-tag text text-warning'>" . get_string('draft', 'theme_snap') . "</div>";
     $canmanagegroups = has_capability('moodle/course:managegroups', context_course::instance($mod->course));
     if ($canmanagegroups && $mod->effectivegroupmode != NOGROUPS) {
         if ($mod->effectivegroupmode == VISIBLEGROUPS) {
             $groupinfo = get_string('groupsvisible');
         } else {
             if ($mod->effectivegroupmode == SEPARATEGROUPS) {
                 $groupinfo = get_string('groupsseparate');
             }
         }
         $assetrestrictions .= "<div class='text'>{$groupinfo}</div>";
     }
     // TODO - ask what this is...
     if (!empty($mod->groupingid) && $canmanagegroups) {
         // Grouping label.
         $groupings = groups_get_all_groupings($mod->course);
         $assetrestrictions .= "<div class='text text-danger'>" . format_string($groupings[$mod->groupingid]->name) . "</div>";
         // TBD - add a title to show this is the Grouping...
     }
     $canviewhidden = has_capability('moodle/course:viewhiddenactivities', $mod->context);
     // If the module isn't available, or we are a teacher (can view hidden activities) then get availability
     // info.
     $availabilityinfo = '';
     if (!$mod->available || $canviewhidden) {
         $availabilityinfo = $this->course_section_cm_availability($mod, $displayoptions);
     }
     if ($availabilityinfo !== '') {
         $conditionalinfo = get_string('conditional', 'theme_snap');
         $assetrestrictions .= "<div class='text text-danger'>{$conditionalinfo}.{$availabilityinfo}</div>";
     }
     $assetrestrictions = "<div class='snap-restrictions-meta'>{$assetrestrictions}</div>";
     $assetmeta .= $assetcompletionmeta . $assetrestrictions;
     // Build output.
     $postcontent = '<div class="snap-asset-meta" data-cmid="' . $mod->id . '">' . $mod->afterlink . $assetmeta . '</div>';
     $output .= $assetlink . $contentpart . $postcontent;
     // Bail at this point if we aren't using a supported format. (Folder view is only partially supported).
     $supported = ['folderview', 'topics', 'weeks', 'site'];
     if (!in_array($COURSE->format, $supported)) {
         return parent::course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions) . $assetmeta;
     }
     // Build up edit actions.
     $actions = '';
     $actionsadvanced = array();
     $coursecontext = context_course::instance($mod->course);
     $modcontext = context_module::instance($mod->id);
     $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
     if (has_capability('moodle/course:update', $modcontext)) {
         $str = get_strings(array('delete', 'move', 'duplicate', 'hide', 'show', 'roles'), 'moodle');
         // TODO - add snap strings here.
         // Move, Edit, Delete.
         if (has_capability('moodle/course:manageactivities', $modcontext)) {
             $movealt = get_string('move', 'theme_snap', $mod->get_formatted_name());
             $moveicon = "<img title='{$movealt}' aria-hidden='true' class='svg-icon' src='" . $this->output->pix_url('move', 'theme') . "' />";
             $editalt = get_string('edit', 'theme_snap', $mod->get_formatted_name());
             $editicon = "<img title='{$editalt}' alt='{$editalt}' class='svg-icon' src='" . $this->output->pix_url('edit', 'theme') . "'/>";
             $actions .= "<input id='snap-move-mod-{$mod->id}' class='js-snap-asset-move sr-only' type='checkbox'><label class='snap-asset-move' for='snap-move-mod-{$mod->id}'><span class='sr-only'>{$movealt}</span>{$moveicon}</label>";
             $actions .= "<a class='snap-edit-asset' href='" . new moodle_url($baseurl, array('update' => $mod->id)) . "'>{$editicon}</a>";
             $actionsadvanced[] = "<a href='" . new moodle_url($baseurl, array('delete' => $mod->id)) . "'>{$str->delete}</a>";
         }
         // Hide/Show.
         if (has_capability('moodle/course:activityvisibility', $modcontext)) {
             $actionsadvanced[] = "<a href='" . new moodle_url($baseurl, array('hide' => $mod->id)) . "' class='editing_hide js_snap_hide'>{$str->hide}</a>";
             $actionsadvanced[] = "<a href='" . new moodle_url($baseurl, array('show' => $mod->id)) . "' class='editing_show js_snap_show'>{$str->show}</a>";
             // AX click to change.
         }
         // Duplicate.
         $dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
         if (has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2) && plugin_supports('mod', $mod->modname, 'duplicate', true)) {
             $actionsadvanced[] = "<a href='" . new moodle_url($baseurl, array('duplicate' => $mod->id)) . "' class='js_snap_duplicate'>{$str->duplicate}</a>";
         }
         // Asign roles.
         if (has_capability('moodle/role:assign', $modcontext)) {
             $actionsadvanced[] = "<a href='" . new moodle_url('/admin/roles/assign.php', array('contextid' => $modcontext->id)) . "'>{$str->roles}</a>";
         }
         // Give local plugins a chance to add icons.
         $localplugins = array();
         foreach (get_plugin_list_with_function('local', 'extend_module_editing_buttons') as $function) {
             $localplugins = array_merge($localplugins, $function($mod));
         }
         // TODO - pld string is far too long....
         $locallinks = '';
         foreach ($localplugins as $localplugin) {
             $url = $localplugin->url;
             $text = $localplugin->text;
             $class = $localplugin->attributes['class'];
             $actionsadvanced[] = "<a href='{$url}' class='{$class}'>{$text}</a>";
         }
     }
     $advancedactions = '';
     if (!empty($actionsadvanced)) {
         $moreicon = "<img title='" . get_string('more', 'theme_snap') . "' alt='" . get_string('more', 'theme_snap') . "' class='svg-icon' src='" . $this->output->pix_url('more', 'theme') . "'/>";
         $advancedactions = "<div class='dropdown snap-edit-more-dropdown'>\n                      <a href='#' class='dropdown-toggle snap-edit-asset-more' data-toggle='dropdown' aria-expanded='false' aria-haspopup='true'>{$moreicon}</a>\n                      <ul class='dropdown-menu'>";
         foreach ($actionsadvanced as $action) {
             $advancedactions .= "<li>{$action}</li>";
         }
         $advancedactions .= "</ul></div>";
     }
     // Add actions menu.
     if ($actions) {
         $output .= "<div class='snap-asset-actions' role='region' aria-label='actions'>";
         $output .= $actions . $advancedactions;
         $output .= "</div>";
     }
     $output .= "</div>";
     // Close .activityinstance.
     $output .= "</div>";
     // Close .asset-wrapper.
     return $output;
 }
Esempio n. 13
0
 public function get_all_my_notes()
 {
     echo \html_writer::tag('p', get_string('mynotes', 'local_note'), ['class' => 'lead']);
     $record = $this->db->get_records("cli_note", array('publisherid' => $this->userid), 'id desc');
     if ($record != null) {
         $table = new \html_table();
         $table->head = (array) get_strings(['serial', 'date', 'course', 'title', 'content', 'attachment', 'label', 'status', 'action'], 'local_note');
         $count = 1;
         foreach ($record as $row) {
             $status = $row->status == true ? '<span class="label label-success">' . get_string('active', 'local_note') . '</span>' : '<span class="label label-warning">' . get_string('inactive', 'local_note') . '</span>';
             $action = '<i class="fa fa-lock" title="Access denied"></i>';
             if ($this->userid == $row->publisherid) {
                 $action = \html_writer::link(new \moodle_url($this->cfg->wwwroot . '/local/note/edit_note.php?id=' . $row->id), '<i class="fa fa-edit"></i> ', ['title' => 'Edit note']);
                 $action .= \html_writer::link(new \moodle_url($this->cfg->wwwroot . '/local/note/delete_note.php?id=' . $row->id), ' <i class="fa fa-trash"></i>', ['title' => 'Delete note']);
             }
             $course = $this->db->get_record('course', array('id' => $row->courseid), 'fullname');
             $table->data[] = array($count++, date('j M Y', $row->createdtime), \html_writer::link(new \moodle_url($this->cfg->wwwroot . '/course/view.php', ['id' => $row->courseid]), $course->fullname), '<a href="view_note.php?id=' . $row->id . '">' . $row->title . '</a>', strip_tags(substr($row->content, 0, 20)) . '&nbsp;<a href="view_note.php?id=' . $row->id . '">' . get_string('more', 'local_note') . '</a>', \html_writer::link(new \moodle_url($this->get_attachment($row->attachment)['url']), $this->get_attachment($row->attachment)['filename'], ['download' => 'download']), $row->label, $status, $action);
         }
         echo \html_writer::start_div('div');
         echo \html_writer::table($table);
         echo \html_writer::end_div('div');
     } else {
         echo \html_writer::div(get_string("nonotesavailable", "local_note"), 'alert alert-warning');
     }
 }
Esempio n. 14
0
        if ($key === false) {
            error(get_string('pluginnotenabled', 'auth', $auth), $url);
        }
        // move up the list
        if ($key >= 1) {
            $fsave = $authsenabled[$key];
            $authsenabled[$key] = $authsenabled[$key - 1];
            $authsenabled[$key - 1] = $fsave;
            set_config('auth', implode(',', $authsenabled));
        }
        break;
    default:
        break;
}
// display strings
$txt = get_strings(array('authenticationplugins', 'users', 'administration', 'settings', 'edit', 'name', 'enable', 'disable', 'up', 'down', 'none'));
$txt->updown = "{$txt->up}/{$txt->down}";
// construct the display array, with enabled auth plugins at the top, in order
$displayauths = array();
$registrationauths = array();
$registrationauths[''] = $txt->disable;
foreach ($authsenabled as $auth) {
    $authplugin = get_auth_plugin($auth);
    /// Get the auth title (from core or own auth lang files)
    $authtitle = get_string("auth_{$auth}title", "auth");
    if ($authtitle == "[[auth_{$auth}title]]") {
        $authtitle = get_string("auth_{$auth}title", "auth_{$auth}");
    }
    /// Apply titles
    $displayauths[$auth] = $authtitle;
    if ($authplugin->can_signup()) {
Esempio n. 15
0
/**
 * Returns the rename action.
 *
 * @param cm_info $mod The module to produce editing buttons for
 * @param int $sr The section to link back to (used for creating the links)
 * @return The markup for the rename action, or an empty string if not available.
 */
function module_get_rename_action($cm, $instance, $sr = null) {
    global $COURSE, $OUTPUT;

    static $str;
    static $baseurl;

    $modcontext = context_module::instance($cm->id);
    $hasmanageactivities = has_capability('mod/virtualclass:recordingupload', $modcontext);

    if (!isset($str)) {
        $str = get_strings(array('edittitle'));
    }

    if (!isset($baseurl)) {
        $baseurl = new moodle_url('edit.php', array('id' => $cm->id, 'sesskey' => sesskey()));
    }

    if ($sr !== null) {
        $baseurl->param('sr', $sr);
    }

    // AJAX edit title.
    /*
if ($mod->has_view() && $hasmanageactivities && course_ajax_enabled($COURSE) &&
                (($mod->course == $COURSE->id) || ($mod->course == SITEID))) {
*/
    if($hasmanageactivities){
        // we will not display link if we are on some other-course page (where we should not see this module anyway)
        return html_writer::span(
            html_writer::link(
                new moodle_url($baseurl, array('update' => $instance->id)),
                $OUTPUT->pix_icon('t/editstring', '', 'moodle', array('class' => 'iconsmall visibleifjs', 'title' => '')),
                array(
                    'class' => 'editing_title',
                    'data-action' => 'edittitle',
                    'title' => $str->edittitle,
                )
            )
        );
    }
    return '';
}
Esempio n. 16
0
/**
 * Get all the strings used in the JavaScript of the edit screen
 * 
 * @return array The strings
 */
function treasurehunt_get_strings_edit()
{
    return get_strings(array('stage', 'road', 'add', 'modify', 'save', 'remove', 'searchlocation', 'savewarning', 'removewarning', 'areyousure', 'removeroadwarning', 'confirm', 'cancel'), 'mod_treasurehunt');
}
Esempio n. 17
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
if (!($site = get_site())) {
    redirect("index.php");
}
/// get language strings
$str = get_strings(array('enrolments', 'users', 'administration', 'settings'));
print_header("{$site->shortname}: {$str->enrolments}", $site->fullname, "<a href=\"../../{$CFG->admin}/index.php\">{$str->administration}</a> -> \n               {$str->enrolments} -> IMS import");
require_once 'enrol.php';
//echo "Creating the IMS Enterprise enroller object\n";
$enrol = new enrolment_plugin_imsenterprise();
?>
<p>Launching the IMS Enterprise "cron" function. The import log will appear below (giving details of any 
problems that might require attention).</p>
<pre style="margin:10px; padding: 2px; border: 1px solid black; background-color: white; color: black;"><?php 
//error_reporting(E_ALL);
$enrol->cron();
?>
</pre><?php 
print_footer();
exit;
Esempio n. 18
0
 /**
  * Returns the list of actions to go in the add menu.
  * @param structure $structure object containing the structure of the quiz.
  * @param int $page the page number that this menu will add to.
  * @param \moodle_url $pageurl the canonical URL of this page.
  * @param array $pagevars the variables from {@link \question_edit_setup()}.
  * @return array the actions.
  */
 public function edit_menu_actions(structure $structure, $page, \moodle_url $pageurl, array $pagevars)
 {
     $questioncategoryid = question_get_category_id_from_pagevars($pagevars);
     static $str;
     if (!isset($str)) {
         $str = get_strings(array('addasection', 'addaquestion', 'addarandomquestion', 'addarandomselectedquestion', 'questionbank'), 'quiz');
     }
     // Get section, page, slotnumber and maxmark.
     $actions = array();
     // Add a new section to the add_menu if possible. This is always added to the HTML
     // then hidden with CSS when no needed, so that as things are re-ordered, etc. with
     // Ajax it can be relevaled again when necessary.
     $params = array('cmid' => $structure->get_cmid(), 'addsectionatpage' => $page);
     $actions['addasection'] = new \action_menu_link_secondary(new \moodle_url($pageurl, $params), new \pix_icon('t/add', $str->addasection, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->addasection, array('class' => 'cm-edit-action addasection', 'data-action' => 'addasection'));
     // Add a new question to the quiz.
     $returnurl = new \moodle_url($pageurl, array('addonpage' => $page));
     $params = array('returnurl' => $returnurl->out_as_local_url(false), 'cmid' => $structure->get_cmid(), 'category' => $questioncategoryid, 'addonpage' => $page, 'appendqnumstring' => 'addquestion');
     $actions['addaquestion'] = new \action_menu_link_secondary(new \moodle_url('/question/addquestion.php', $params), new \pix_icon('t/add', $str->addaquestion, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->addaquestion, array('class' => 'cm-edit-action addquestion', 'data-action' => 'addquestion'));
     // Call question bank.
     $icon = new \pix_icon('t/add', $str->questionbank, 'moodle', array('class' => 'iconsmall', 'title' => ''));
     if ($page) {
         $title = get_string('addquestionfrombanktopage', 'quiz', $page);
     } else {
         $title = get_string('addquestionfrombankatend', 'quiz');
     }
     $attributes = array('class' => 'cm-edit-action questionbank', 'data-header' => $title, 'data-action' => 'questionbank', 'data-addonpage' => $page);
     $actions['questionbank'] = new \action_menu_link_secondary($pageurl, $icon, $str->questionbank, $attributes);
     // Add a random question.
     $returnurl = new \moodle_url('/mod/quiz/edit.php', array('cmid' => $structure->get_cmid(), 'data-addonpage' => $page));
     $params = array('returnurl' => $returnurl, 'cmid' => $structure->get_cmid(), 'appendqnumstring' => 'addarandomquestion');
     $url = new \moodle_url('/mod/quiz/addrandom.php', $params);
     $icon = new \pix_icon('t/add', $str->addarandomquestion, 'moodle', array('class' => 'iconsmall', 'title' => ''));
     $attributes = array('class' => 'cm-edit-action addarandomquestion', 'data-action' => 'addarandomquestion');
     if ($page) {
         $title = get_string('addrandomquestiontopage', 'quiz', $page);
     } else {
         $title = get_string('addrandomquestionatend', 'quiz');
     }
     $attributes = array_merge(array('data-header' => $title, 'data-addonpage' => $page), $attributes);
     $actions['addarandomquestion'] = new \action_menu_link_secondary($url, $icon, $str->addarandomquestion, $attributes);
     return $actions;
 }
Esempio n. 19
0
 /**
  * Builds the XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/licenselib.php';
     $url = "licenses.php?sesskey=" . sesskey();
     // display strings
     $txt = get_strings(array('administration', 'settings', 'name', 'enable', 'disable', 'none'));
     $licenses = license_manager::get_licenses();
     $return = $OUTPUT->heading(get_string('availablelicenses', 'admin'), 3, 'main', true);
     $return .= $OUTPUT->box_start('generalbox editorsui');
     $table = new html_table();
     $table->head = array($txt->name, $txt->enable);
     $table->align = array('left', 'center');
     $table->width = '100%';
     $table->data = array();
     foreach ($licenses as $value) {
         $displayname = html_writer::link($value->source, get_string($value->shortname, 'license'), array('target' => '_blank'));
         if ($value->enabled == 1) {
             $hideshow = html_writer::link($url . '&action=disable&license=' . $value->shortname, html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/hide'), 'class' => 'icon', 'alt' => 'disable')));
         } else {
             $hideshow = html_writer::link($url . '&action=enable&license=' . $value->shortname, html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/show'), 'class' => 'icon', 'alt' => 'enable')));
         }
         if ($value->shortname == $CFG->sitedefaultlicense) {
             $displayname .= ' ' . html_writer::tag('img', '', array('src' => $OUTPUT->pix_url('i/lock'), 'class' => 'icon', 'alt' => get_string('default'), 'title' => get_string('default')));
             $hideshow = '';
         }
         $enabled = true;
         $table->data[] = array($displayname, $hideshow);
     }
     $return .= html_writer::table($table);
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
 /**
  * Returns the list of actions to go in the add menu.
  * @param structure $structure object containing the structure of the quiz.
  * @param int $page the page number that this menu will add to.
  * @param \moodle_url $pageurl the canonical URL of this page.
  * @param array $pagevars the variables from {@link \question_edit_setup()}.
  * @return array the actions.
  */
 public function edit_menu_actions(structure $structure, $page, \moodle_url $pageurl, array $pagevars)
 {
     $questioncategoryid = question_get_category_id_from_pagevars($pagevars);
     static $str;
     if (!isset($str)) {
         $str = get_strings(array('addaquestion', 'addarandomquestion', 'addarandomselectedquestion', 'questionbank'), 'quiz');
     }
     // Get section, page, slotnumber and maxmark.
     $actions = array();
     // Add a new question to the quiz.
     $returnurl = new \moodle_url($pageurl, array('addonpage' => $page));
     $params = array('returnurl' => $returnurl->out_as_local_url(false), 'cmid' => $structure->get_cmid(), 'category' => $questioncategoryid, 'addonpage' => $page, 'appendqnumstring' => 'addquestion');
     $actions['addaquestion'] = new \action_menu_link_secondary(new \moodle_url('/question/addquestion.php', $params), new \pix_icon('t/add', $str->addaquestion, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->addaquestion, array('class' => 'cm-edit-action addquestion', 'data-action' => 'addquestion'));
     // Call question bank.
     $icon = new \pix_icon('t/add', $str->questionbank, 'moodle', array('class' => 'iconsmall', 'title' => ''));
     $title = get_string('addquestionfrombanktopage', 'quiz', $page);
     $attributes = array('class' => 'cm-edit-action questionbank', 'data-header' => $title, 'data-action' => 'questionbank', 'data-addonpage' => $page);
     $actions['questionbank'] = new \action_menu_link_secondary($pageurl, $icon, $str->questionbank, $attributes);
     // Add a random question.
     $returnurl = new \moodle_url('/mod/quiz/edit.php', array('cmid' => $structure->get_cmid(), 'data-addonpage' => $page));
     $params = array('returnurl' => $returnurl, 'cmid' => $structure->get_cmid(), 'appendqnumstring' => 'addarandomquestion');
     $url = new \moodle_url('/mod/quiz/addrandom.php', $params);
     $icon = new \pix_icon('t/add', $str->addarandomquestion, 'moodle', array('class' => 'iconsmall', 'title' => ''));
     $attributes = array('class' => 'cm-edit-action addarandomquestion', 'data-action' => 'addarandomquestion');
     $title = get_string('addrandomquestiontopage', 'quiz', $page);
     $attributes = array_merge(array('data-header' => $title, 'data-addonpage' => $page), $attributes);
     $actions['addarandomquestion'] = new \action_menu_link_secondary($url, $icon, $str->addarandomquestion, $attributes);
     return $actions;
 }
Esempio n. 21
0
/**
 * Returns the move action.
 *
 * @param cm_info $mod The module to produce a move button for
 * @param int $sr The section to link back to (used for creating the links)
 * @return The markup for the move action, or an empty string if not available.
 */
function course_get_cm_move(cm_info $mod, $sr = null)
{
    global $OUTPUT;
    static $str;
    static $baseurl;
    $modcontext = context_module::instance($mod->id);
    $hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
    if (!isset($str)) {
        $str = get_strings(array('move'));
    }
    if (!isset($baseurl)) {
        $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
        if ($sr !== null) {
            $baseurl->param('sr', $sr);
        }
    }
    if ($hasmanageactivities) {
        $pixicon = 'i/dragdrop';
        if (!course_ajax_enabled($mod->get_course())) {
            // Override for course frontpage until we get drag/drop working there.
            $pixicon = 't/move';
        }
        return html_writer::link(new moodle_url($baseurl, array('copy' => $mod->id)), $OUTPUT->pix_icon($pixicon, $str->move, 'moodle', array('class' => 'iconsmall', 'title' => '')), array('class' => 'editing_move', 'data-action' => 'move'));
    }
    return '';
}
Esempio n. 22
0
 /**
  * Return XHTML to display control
  *
  * @param mixed $data Unused
  * @param string $query
  * @return string highlight
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     $return = '';
     $formats = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
     $txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default'));
     $txt->uninstall = get_string('uninstallplugin', 'core_admin');
     $txt->updown = "{$txt->up}/{$txt->down}";
     $table = new html_table();
     $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->uninstall, $txt->settings);
     $table->align = array('left', 'center', 'center', 'center', 'center');
     $table->attributes['class'] = 'manageformattable generaltable admintable';
     $table->data = array();
     $cnt = 0;
     $spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'iconsmall'));
     $totalenabled = 0;
     foreach ($formats as $format) {
         if ($format->is_enabled() && $format->is_installed_and_upgraded()) {
             $totalenabled++;
         }
     }
     foreach ($formats as $format) {
         $status = $format->get_status();
         $url = new moodle_url('/admin/dataformats.php', array('sesskey' => sesskey(), 'name' => $format->name));
         $class = '';
         if ($format->is_enabled()) {
             $strformatname = $format->displayname;
             if ($totalenabled == 1 && $format->is_enabled()) {
                 $hideshow = '';
             } else {
                 $hideshow = html_writer::link($url->out(false, array('action' => 'disable')), $OUTPUT->pix_icon('t/hide', $txt->disable, 'moodle', array('class' => 'iconsmall')));
             }
         } else {
             $class = 'dimmed_text';
             $strformatname = $format->displayname;
             $hideshow = html_writer::link($url->out(false, array('action' => 'enable')), $OUTPUT->pix_icon('t/show', $txt->enable, 'moodle', array('class' => 'iconsmall')));
         }
         $updown = '';
         if ($cnt) {
             $updown .= html_writer::link($url->out(false, array('action' => 'up')), $OUTPUT->pix_icon('t/up', $txt->up, 'moodle', array('class' => 'iconsmall'))) . '';
         } else {
             $updown .= $spacer;
         }
         if ($cnt < count($formats) - 1) {
             $updown .= '&nbsp;' . html_writer::link($url->out(false, array('action' => 'down')), $OUTPUT->pix_icon('t/down', $txt->down, 'moodle', array('class' => 'iconsmall')));
         } else {
             $updown .= $spacer;
         }
         $uninstall = '';
         if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
             $uninstall = get_string('status_missing', 'core_plugin');
         } else {
             if ($status === core_plugin_manager::PLUGIN_STATUS_NEW) {
                 $uninstall = get_string('status_new', 'core_plugin');
             } else {
                 if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('dataformat_' . $format->name, 'manage')) {
                     if ($totalenabled != 1 || !$format->is_enabled()) {
                         $uninstall = html_writer::link($uninstallurl, $txt->uninstall);
                     }
                 }
             }
         }
         $settings = '';
         if ($format->get_settings_url()) {
             $settings = html_writer::link($format->get_settings_url(), $txt->settings);
         }
         $row = new html_table_row(array($strformatname, $hideshow, $updown, $uninstall, $settings));
         if ($class) {
             $row->attributes['class'] = $class;
         }
         $table->data[] = $row;
         $cnt++;
     }
     $return .= html_writer::table($table);
     return highlight($query, $return);
 }
Esempio n. 23
0
 /**
  * Return XHTML to display control
  *
  * @param mixed $data Unused
  * @param string $query
  * @return string highlight
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     $return = '';
     $return = $OUTPUT->heading(new lang_string('courseformats'), 3, 'main');
     $return .= $OUTPUT->box_start('generalbox formatsui');
     $formats = core_plugin_manager::instance()->get_plugins_of_type('format');
     // display strings
     $txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default'));
     $txt->uninstall = get_string('uninstallplugin', 'core_admin');
     $txt->updown = "{$txt->up}/{$txt->down}";
     $table = new html_table();
     $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->uninstall, $txt->settings);
     $table->align = array('left', 'center', 'center', 'center', 'center');
     $table->attributes['class'] = 'manageformattable generaltable admintable';
     $table->data = array();
     $cnt = 0;
     $defaultformat = get_config('moodlecourse', 'format');
     $spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'iconsmall'));
     foreach ($formats as $format) {
         $url = new moodle_url('/admin/courseformats.php', array('sesskey' => sesskey(), 'format' => $format->name));
         $isdefault = '';
         $class = '';
         if ($format->is_enabled()) {
             $strformatname = $format->displayname;
             if ($defaultformat === $format->name) {
                 $hideshow = $txt->default;
             } else {
                 $hideshow = html_writer::link($url->out(false, array('action' => 'disable')), $OUTPUT->pix_icon('t/hide', $txt->disable, 'moodle', array('class' => 'iconsmall')));
             }
         } else {
             $strformatname = $format->displayname;
             $class = 'dimmed_text';
             $hideshow = html_writer::link($url->out(false, array('action' => 'enable')), $OUTPUT->pix_icon('t/show', $txt->enable, 'moodle', array('class' => 'iconsmall')));
         }
         $updown = '';
         if ($cnt) {
             $updown .= html_writer::link($url->out(false, array('action' => 'up')), $OUTPUT->pix_icon('t/up', $txt->up, 'moodle', array('class' => 'iconsmall'))) . '';
         } else {
             $updown .= $spacer;
         }
         if ($cnt < count($formats) - 1) {
             $updown .= '&nbsp;' . html_writer::link($url->out(false, array('action' => 'down')), $OUTPUT->pix_icon('t/down', $txt->down, 'moodle', array('class' => 'iconsmall')));
         } else {
             $updown .= $spacer;
         }
         $cnt++;
         $settings = '';
         if ($format->get_settings_url()) {
             $settings = html_writer::link($format->get_settings_url(), $txt->settings);
         }
         $uninstall = '';
         if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('format_' . $format->name, 'manage')) {
             $uninstall = html_writer::link($uninstallurl, $txt->uninstall);
         }
         $row = new html_table_row(array($strformatname, $hideshow, $updown, $uninstall, $settings));
         if ($class) {
             $row->attributes['class'] = $class;
         }
         $table->data[] = $row;
     }
     $return .= html_writer::table($table);
     $link = html_writer::link(new moodle_url('/admin/settings.php', array('section' => 'coursesettings')), new lang_string('coursesettings'));
     $return .= html_writer::tag('p', get_string('manageformatsgotosettings', 'admin', $link));
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
Esempio n. 24
0
 /**
  * Builds the XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     // display strings
     $txt = get_strings(array('administration', 'settings', 'edit', 'name', 'enable', 'disable', 'up', 'down', 'none'));
     $txt->updown = "{$txt->up}/{$txt->down}";
     $editors_available = get_available_editors();
     $active_editors = explode(',', $CFG->texteditors);
     $active_editors = array_reverse($active_editors);
     foreach ($active_editors as $key => $editor) {
         if (empty($editors_available[$editor])) {
             unset($active_editors[$key]);
         } else {
             $name = $editors_available[$editor];
             unset($editors_available[$editor]);
             $editors_available[$editor] = $name;
         }
     }
     if (empty($active_editors)) {
         //$active_editors = array('textarea');
     }
     $editors_available = array_reverse($editors_available, true);
     $return = $OUTPUT->heading(get_string('acteditorshhdr', 'editor'), 3, 'main', true);
     $return .= $OUTPUT->box_start('generalbox editorsui');
     $table = new html_table();
     $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings);
     $table->align = array('left', 'center', 'center', 'center');
     $table->width = '90%';
     $table->data = array();
     // iterate through auth plugins and add to the display table
     $updowncount = 1;
     $editorcount = count($active_editors);
     $url = "editors.php?sesskey=" . sesskey();
     foreach ($editors_available as $editor => $name) {
         // hide/show link
         if (in_array($editor, $active_editors)) {
             $hideshow = "<a href=\"{$url}&amp;action=disable&amp;editor={$editor}\">";
             $hideshow .= "<img src=\"" . $OUTPUT->old_icon_url('i/hide') . "\" class=\"icon\" alt=\"disable\" /></a>";
             // $hideshow = "<a href=\"$url&amp;action=disable&amp;editor=$editor\"><input type=\"checkbox\" checked /></a>";
             $enabled = true;
             $displayname = "<span>{$name}</span>";
         } else {
             $hideshow = "<a href=\"{$url}&amp;action=enable&amp;editor={$editor}\">";
             $hideshow .= "<img src=\"" . $OUTPUT->old_icon_url('i/show') . "\" class=\"icon\" alt=\"enable\" /></a>";
             // $hideshow = "<a href=\"$url&amp;action=enable&amp;editor=$editor\"><input type=\"checkbox\" /></a>";
             $enabled = false;
             $displayname = "<span class=\"dimmed_text\">{$name}</span>";
         }
         // up/down link (only if auth is enabled)
         $updown = '';
         if ($enabled) {
             if ($updowncount > 1) {
                 $updown .= "<a href=\"{$url}&amp;action=up&amp;editor={$editor}\">";
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('t/up') . "\" alt=\"up\" /></a>&nbsp;";
             } else {
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('spacer.gif') . "\" class=\"icon\" alt=\"\" />&nbsp;";
             }
             if ($updowncount < $editorcount) {
                 $updown .= "<a href=\"{$url}&amp;action=down&amp;editor={$editor}\">";
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('t/down') . "\" alt=\"down\" /></a>";
             } else {
                 $updown .= "<img src=\"" . $OUTPUT->old_icon_url('spacer.gif') . "\" class=\"icon\" alt=\"\" />";
             }
             ++$updowncount;
         }
         // settings link
         if (file_exists($CFG->dirroot . '/editor/' . $editor . '/settings.php')) {
             $settings = "<a href=\"settings.php?section=editorsetting{$editor}\">{$txt->settings}</a>";
         } else {
             $settings = '';
         }
         // add a row to the table
         $table->data[] = array($displayname, $hideshow, $updown, $settings);
     }
     $return .= $OUTPUT->table($table);
     $return .= get_string('configeditorplugins', 'editor') . '<br />' . get_string('tablenosave', 'filters');
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
Esempio n. 25
0
 /**
  * Return XHTML to display control
  *
  * @param mixed $data Unused
  * @param string $query
  * @return string highlight
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     // display strings
     $txt = get_strings(array('settings', 'name'));
     $plagiarismplugins = get_plugin_list('plagiarism');
     if (empty($plagiarismplugins)) {
         return get_string('nopluginsinstalled', 'plagiarism');
     }
     $return = $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main');
     $return .= $OUTPUT->box_start('generalbox authsui');
     $table = new html_table();
     $table->head = array($txt->name, $txt->settings);
     $table->align = array('left', 'center');
     $table->data = array();
     $table->attributes['class'] = 'manageplagiarismtable generaltable';
     // iterate through auth plugins and add to the display table
     $authcount = count($plagiarismplugins);
     foreach ($plagiarismplugins as $plugin => $dir) {
         if (file_exists($dir . '/settings.php')) {
             $displayname = "<span>" . get_string($plugin, 'plagiarism_' . $plugin) . "</span>";
             // settings link
             $settings = "<a href=\"{$CFG->wwwroot}/plagiarism/{$plugin}/settings.php\">{$txt->settings}</a>";
             // add a row to the table
             $table->data[] = array($displayname, $settings);
         }
     }
     $return .= html_writer::table($table);
     $return .= get_string('configplagiarismplugins', 'plagiarism');
     $return .= $OUTPUT->box_end();
     return highlight($query, $return);
 }
Esempio n. 26
0
function __($str)
{
    global $lang;
    if (!isset($lang)) {
        return $str;
    }
    $strings = get_strings($lang);
    if (!$strings) {
        return $str;
    }
    $strings = (array) $strings;
    if (array_key_exists($str, $strings)) {
        return $strings[$str];
    }
    return $str;
}