コード例 #1
0
    echo $OUTPUT->footer();
    die;
}
$hub = new local_hub();
/// Check if the page has been called with trust argument
$delete = optional_param('delete', -1, PARAM_INTEGER);
$confirm = optional_param('confirm', false, PARAM_INTEGER);
if ($delete != -1 and $confirm and confirm_sesskey()) {
    $unregistercourses = optional_param('unregistercourses', false, PARAM_BOOL);
    $hub->delete_site($delete, $unregistercourses);
}
/// Check if the page has been called with trust argument
$trust = optional_param('trust', -1, PARAM_INTEGER);
if ($trust != -1 and confirm_sesskey()) {
    $id = required_param('id', PARAM_INTEGER);
    $site = $hub->get_site($id);
    if (!empty($site)) {
        $site->trusted = $trust;
        $hub->update_site($site);
    }
}
$search = optional_param('search', '', PARAM_TEXT);
$renderer = $PAGE->get_renderer('local_hub');
$contenthtml = "";
$moresiteshtml = "";
if ($delete != -1 and !$confirm) {
    //we want to display delete confirmation page
    $site = $hub->get_site($delete);
    $contenthtml = $renderer->delete_confirmation($site);
} else {
    //all other cases we go back to site list page (no need confirmation)
コード例 #2
0
require_once $CFG->dirroot . '/local/hub/lib.php';
require_once $CFG->dirroot . "/local/hub/admin/forms.php";
admin_externalpage_setup('hubstolensecret');
$hub = new local_hub();
$renderer = $PAGE->get_renderer('local_hub');
$stolen = optional_param('stolen', 0, PARAM_INT);
if ($stolen and sesskey()) {
    $confirm = optional_param('confirm', 0, PARAM_INT);
    if ($confirm) {
        //mark the token as stolen
        $hub->marksecretstolen($stolen);
        //delete site and web service token
        $hub->delete_site($stolen);
        $confirmmsg = $OUTPUT->notification(get_string('secretblocked', 'local_hub'), 'notifysuccess');
    } else {
        $hackedsite = $hub->get_site($stolen);
        echo $OUTPUT->header();
        echo $OUTPUT->heading(get_string('stolensecret', 'local_hub'));
        echo $renderer->stolensecret_confirmation($hackedsite);
        echo $OUTPUT->footer();
        die;
    }
}
$mform = new hub_search_stolen_secret();
if ($data = $mform->get_data()) {
    $sites = array();
    //search site
    if (!empty($data->secret)) {
        //by token
        $site = $hub->get_site_by_secret($data->secret);
        if (!empty($site)) {
コード例 #3
0
ファイル: forms.php プロジェクト: scyrma/moodle-local_hub
 public function definition()
 {
     //retrieve the publication
     $hub = new local_hub();
     $site = $hub->get_site($this->_customdata['id']);
     $mform =& $this->_form;
     $mform->addElement('header', 'moodle', get_string('sitesettingsform', 'local_hub', $site->name));
     $mform->addElement('hidden', 'id', $site->id);
     $mform->addElement('text', 'name', get_string('sitename', 'local_hub'));
     $mform->addHelpButton('name', 'sitename', 'local_hub');
     $mform->setDefault('name', $site->name);
     $mform->addElement('text', 'url', get_string('siteurl', 'local_hub'));
     $mform->addHelpButton('url', 'siteurl', 'local_hub');
     $mform->setDefault('url', $site->url);
     $mform->addElement('textarea', 'description', get_string('sitedesc', 'local_hub'));
     $mform->addHelpButton('description', 'sitedesc', 'local_hub');
     $mform->setDefault('description', $site->description);
     $mform->addElement('text', 'contactname', get_string('siteadmin', 'local_hub'));
     $mform->addHelpButton('contactname', 'siteadmin', 'local_hub');
     $mform->setDefault('contactname', $site->contactname);
     $mform->addElement('text', 'contactemail', get_string('siteadminemail', 'local_hub'));
     $mform->addHelpButton('contactemail', 'siteadminemail', 'local_hub');
     $mform->setDefault('contactemail', $site->contactemail);
     $languages = get_string_manager()->get_list_of_languages();
     asort($languages, SORT_LOCALE_STRING);
     $mform->addElement('select', 'language', get_string('sitelanguage', 'local_hub'), $languages);
     $mform->setDefault('language', $site->language);
     $mform->addHelpButton('language', 'sitelanguage', 'local_hub');
     $countries = get_string_manager()->get_list_of_countries();
     $mform->addElement('select', 'countrycode', get_string('sitecountry', 'local_hub'), $countries);
     $mform->setDefault('countrycode', $site->countrycode);
     $mform->addHelpButton('countrycode', 'sitecountry', 'local_hub');
     $mform->addElement('text', 'publicationmax', get_string('publicationmax', 'local_hub'));
     $mform->addHelpButton('publicationmax', 'publicationmax', 'local_hub');
     $mform->setDefault('publicationmax', $site->publicationmax);
     $this->add_action_buttons(false, get_string('update'));
 }
コード例 #4
0
//                                                                       //
///////////////////////////////////////////////////////////////////////////
/**
 * On this page administrator can change site settings
 * @package   localhub
 * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
 * @author    Jerome Mouneyrac
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require '../../../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->dirroot . '/local/hub/admin/forms.php';
admin_externalpage_setup('sitesettings');
$id = optional_param('id', 0, PARAM_INT);
$hub = new local_hub();
$site = $hub->get_site($id, MUST_EXIST);
//define nav bar
$PAGE->set_url('/local/hub/admin/sitesettings.php', array('id' => $id));
$PAGE->navbar->ignore_active(true);
$PAGE->navbar->add(get_string('administrationsite'));
$PAGE->navbar->add(get_string('hub', 'local_hub'));
$PAGE->navbar->add(get_string('managesites', 'local_hub'), new moodle_url('/local/hub/admin/managesites.php', array('search' => $site->name, 'sesskey' => sesskey())));
$PAGE->navbar->add(get_string('sitesettings', 'local_hub'), new moodle_url('/local/hub/admin/sitesettings.php', array('id' => $id)));
$sitesettingsform = new hub_site_settings_form('', array('id' => $id));
$fromform = $sitesettingsform->get_data();
//Save settings and redirect to search site page
if (!empty($fromform)) {
    if ($fromform->publicationmax === '') {
        $site->publicationmax = null;
    } else {
        $site->publicationmax = $fromform->publicationmax;