first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,141 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin Bookmarks Block page.
*
* @package block_admin_bookmarks
* @copyright 2011 Moodle
* @author 2006 vinkmar
* 2011 Rossiani Wijaya (updated)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* The admin bookmarks block class
*/
class block_admin_bookmarks extends block_base {
/** @var string */
public $blockname = null;
/** @var bool|null */
protected $docked = null;
/**
* Set the initial properties for the block
*/
function init() {
$this->blockname = get_class($this);
$this->title = get_string('pluginname', $this->blockname);
}
/**
* All multiple instances of this block
* @return bool Returns false
*/
function instance_allow_multiple() {
return false;
}
/**
* Set the applicable formats for this block to all
* @return array
*/
function applicable_formats() {
if (has_capability('moodle/site:config', context_system::instance())) {
return array('all' => true);
} else {
return array('site' => true);
}
}
/**
* Gets the content for this block
*/
function get_content() {
global $CFG;
// First check if we have already generated, don't waste cycles
if ($this->content !== null) {
return $this->content;
}
$this->content = new stdClass();
if (get_user_preferences('admin_bookmarks')) {
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root(false, false); // settings not required - only pages
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
/// Accessibility: markup as a list.
$contents = array();
foreach($bookmarks as $bookmark) {
$temp = $adminroot->locate($bookmark);
if ($temp instanceof admin_settingpage) {
$contenturl = new moodle_url('/admin/settings.php', array('section'=>$bookmark));
$contentlink = html_writer::link($contenturl, $temp->visiblename);
$contents[] = html_writer::tag('li', $contentlink);
} else if ($temp instanceof admin_externalpage) {
$contenturl = new moodle_url($temp->url);
$contentlink = html_writer::link($contenturl, $temp->visiblename);
$contents[] = html_writer::tag('li', $contentlink);
} else if ($temp instanceof admin_category) {
$contenturl = new moodle_url('/admin/category.php', array('category' => $bookmark));
$contentlink = html_writer::link($contenturl, $temp->visiblename);
$contents[] = html_writer::tag('li', $contentlink);
}
}
$this->content->text = html_writer::tag('ol', implode('', $contents), array('class' => 'list'));
} else {
$bookmarks = array();
}
$this->content->footer = '';
$this->page->settingsnav->initialise();
$node = $this->page->settingsnav->get('root', navigation_node::TYPE_SITE_ADMIN);
if (!$node || !$node->contains_active_node()) {
return $this->content;
}
$section = $node->find_active_node()->key;
if ($section == 'search' || empty($section)){
// the search page can't be properly bookmarked at present
$this->content->footer = '';
} else if (in_array($section, $bookmarks)) {
$deleteurl = new moodle_url('/blocks/admin_bookmarks/delete.php', array('section'=>$section, 'sesskey'=>sesskey()));
$this->content->footer = html_writer::link($deleteurl, get_string('unbookmarkthispage','admin'));
} else {
$createurl = new moodle_url('/blocks/admin_bookmarks/create.php', array('section'=>$section, 'sesskey'=>sesskey()));
$this->content->footer = html_writer::link($createurl, get_string('bookmarkthispage','admin'));
}
return $this->content;
}
/**
* Returns the role that best describes the admin bookmarks block.
*
* @return string
*/
public function get_aria_role() {
return 'navigation';
}
}
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for block_admin_bookmarks.
*
* @package block_admin_bookmarks
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_admin_bookmarks\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for block_admin_bookmarks implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+76
View File
@@ -0,0 +1,76 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Create admin bookmarks.
*
* @package block_admin_bookmarks
* @copyright 2006 vinkmar
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_login();
$context = context_system::instance();
$PAGE->set_context($context);
$adminroot = admin_get_root(false, false); // settings not required - only pages
// We clean section with safe path here for compatibility with external pages that include a slash in their name.
if ($section = optional_param('section', '', PARAM_SAFEPATH) and confirm_sesskey()) {
if (get_user_preferences('admin_bookmarks')) {
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
if (in_array($section, $bookmarks)) {
throw new \moodle_exception('bookmarkalreadyexists', 'admin');
die;
}
} else {
$bookmarks = array();
}
$temp = $adminroot->locate($section);
if ($temp instanceof admin_settingpage || $temp instanceof admin_externalpage || $temp instanceof admin_category) {
$bookmarks[] = $section;
$bookmarks = implode(',', $bookmarks);
set_user_preference('admin_bookmarks', $bookmarks);
} else {
throw new \moodle_exception('invalidsection', 'admin');
die;
}
if ($temp instanceof admin_settingpage) {
redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
} elseif ($temp instanceof admin_externalpage) {
redirect($temp->url);
} else if ($temp instanceof admin_category) {
redirect($CFG->wwwroot . '/' . $CFG->admin . '/category.php?category=' . $section);
}
} else {
throw new \moodle_exception('invalidsection', 'admin');
die;
}
+51
View File
@@ -0,0 +1,51 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin bookmarks block caps.
*
* @package block_admin_bookmarks
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/admin_bookmarks:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/admin_bookmarks:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
+76
View File
@@ -0,0 +1,76 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Delete admin bookmarks.
*
* @package block_admin_bookmarks
* @copyright 2006 vinkmar
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_login();
$context = context_system::instance();
$PAGE->set_context($context);
$adminroot = admin_get_root(false, false); // settings not required - only pages
// We clean section with safe path here for compatibility with external pages that include a slash in their name.
if ($section = optional_param('section', '', PARAM_SAFEPATH) and confirm_sesskey()) {
if (get_user_preferences('admin_bookmarks')) {
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
$key = array_search($section, $bookmarks);
if ($key === false) {
throw new \moodle_exception('nonexistentbookmark', 'admin');
die;
}
unset($bookmarks[$key]);
$bookmarks = implode(',', $bookmarks);
set_user_preference('admin_bookmarks', $bookmarks);
$temp = $adminroot->locate($section);
if ($temp instanceof admin_externalpage) {
redirect($temp->url, get_string('bookmarkdeleted','admin'));
} elseif ($temp instanceof admin_settingpage) {
redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
} else if ($temp instanceof admin_category) {
redirect($CFG->wwwroot . '/' . $CFG->admin . '/category.php?category=' . $section);
} else {
redirect($CFG->wwwroot);
}
die;
}
throw new \moodle_exception('nobookmarksforuser', 'admin');
die;
} else {
throw new \moodle_exception('invalidsection', 'admin');
die;
}
@@ -0,0 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'block_admin_bookmarks', language 'en', branch 'MOODLE_20_STABLE'
*
* @package block_admin_bookmarks
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['admin_bookmarks:addinstance'] = 'Add a new admin bookmarks block';
$string['admin_bookmarks:myaddinstance'] = 'Add a new admin bookmarks block to Dashboard';
$string['pluginname'] = 'Admin bookmarks';
$string['privacy:metadata'] = 'The Admin bookmarks block only shows data stored in other locations.';
@@ -0,0 +1,36 @@
@block @block_admin_bookmarks
Feature: Add a bookmarks to an admin pages
In order to speed up common tasks
As an admin
I need to add and access pages through bookmarks
Background:
Given I log in as "admin"
And I navigate to "Server > Tasks > Scheduled tasks" in site administration
And I click on "Bookmark this page" "link" in the "Admin bookmarks" "block"
And I log out
# Test bookmark functionality using the "User profile fields" page as our bookmark.
Scenario: Admin page can be bookmarked
Given I log in as "admin"
And I navigate to "Users > Accounts > User profile fields" in site administration
When I click on "Bookmark this page" "link" in the "Admin bookmarks" "block"
Then I should see "User profile fields" in the "Admin bookmarks" "block"
# See the existing bookmark is there too.
And I should see "Scheduled tasks" in the "Admin bookmarks" "block"
Scenario: Admin page can be accessed through bookmarks block
Given I log in as "admin"
And I navigate to "Notifications" in site administration
And I click on "Scheduled tasks" "link" in the "Admin bookmarks" "block"
# Verify that we are on the right page.
Then I should see "Day of week" in the "admintable" "table"
Scenario: Admin page can be removed from bookmarks
Given I log in as "admin"
And I navigate to "Notifications" in site administration
And I click on "Scheduled tasks" "link" in the "Admin bookmarks" "block"
When I click on "Unbookmark this page" "link" in the "Admin bookmarks" "block"
Then I should see "Bookmark deleted"
And I wait to be redirected
And I should not see "Scheduled tasks" in the "Admin bookmarks" "block"
+29
View File
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details
*
* @package block_admin_bookmarks
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2024041600; // Requires this Moodle version.
$plugin->component = 'block_admin_bookmarks'; // Full name of the plugin (used for diagnostics)