Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 27... Línea 27...
27
 * @package   core_badges
27
 * @package   core_badges
28
 * @copyright 2021 Peter Dias
28
 * @copyright 2021 Peter Dias
29
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
30
 */
31
class standard_action_bar extends base_action_bar {
31
class standard_action_bar extends base_action_bar {
32
    /** @var bool $showmanage Whether or not to show the manage badges button. */
-
 
33
    protected $showmanage;
-
 
34
 
-
 
35
    /** @var bool $showaddbadge Whether or not to show the add badges button. */
-
 
36
    protected $showaddbadge;
-
 
37
 
-
 
38
    /** @var moodle_url $backurl BackURL to be used when the back button is required. */
-
 
39
    protected $backurl;
-
 
40
 
-
 
41
    /**
32
    /**
42
     * standard_action_bar constructor
33
     * The constructor.
43
     *
34
     *
44
     * @param moodle_page $page The page object
-
 
45
     * @param int $type The type of badge we are operating with
-
 
46
     * @param bool $showmanage Whether or not to show the manage badges button
-
 
47
     * @param bool $showaddbadge Whether or not to show the add badges button
-
 
48
     * @param moodle_url|null $backurl The backurl to be used
-
 
49
     */
35
     */
-
 
36
    public function __construct(
-
 
37
        moodle_page $page,
-
 
38
        int $type,
-
 
39
        /** @var null|bool $showmanage This parameter has been deprecated since 4.5 and should not be used anymore. */
-
 
40
        ?bool $showmanage = null,
50
    public function __construct(moodle_page $page, int $type, bool $showmanage = true,
41
        /** @var bool $showaddbadge Whether or not to show the add badges button. */
-
 
42
        protected bool $showaddbadge = true,
-
 
43
        /** @var moodle_url $backurl BackURL to be used when the back button is required. */
51
            $showaddbadge = true, ?moodle_url $backurl = null) {
44
        protected ?moodle_url $backurl = null,
-
 
45
    ) {
52
        parent::__construct($page, $type);
46
        parent::__construct($page, $type);
Línea 53... Línea 47...
53
 
47
 
-
 
48
        if ($showmanage !== null) {
-
 
49
            debugging(
-
 
50
                'The showmanage argument has been deprecated. Please remove it from your method calls.',
-
 
51
                DEBUG_DEVELOPER,
-
 
52
            );
-
 
53
        }
54
        $this->showmanage = $showmanage;
54
 
55
        $this->showaddbadge = $showaddbadge;
55
        $this->showaddbadge = $showaddbadge;
56
        $this->backurl = $backurl;
56
        $this->backurl = $backurl;
Línea 57... Línea 57...
57
    }
57
    }
Línea 80... Línea 80...
80
        $params = ['type' => $this->type];
80
        $params = ['type' => $this->type];
81
        if ($this->page->context->contextlevel == CONTEXT_COURSE) {
81
        if ($this->page->context->contextlevel == CONTEXT_COURSE) {
82
            $params['id'] = $this->page->context->instanceid;
82
            $params['id'] = $this->page->context->instanceid;
83
        }
83
        }
Línea 84... Línea -...
84
 
-
 
85
        if ($this->showmanage) {
-
 
86
            $buttons[] = new single_button(new moodle_url('/badges/index.php', $params),
-
 
87
                get_string('managebadges', 'core_badges'), 'get');
-
 
88
        }
-
 
89
 
84
 
-
 
85
        if ($this->showaddbadge && has_capability('moodle/badges:createbadge', $this->page->context)) {
-
 
86
            $editparams = ['action' => 'new'];
-
 
87
            if (array_key_exists('id', $params)) {
-
 
88
                $editparams['courseid'] = $params['id'];
90
        if ($this->showaddbadge && has_capability('moodle/badges:createbadge', $this->page->context)) {
89
            }
-
 
90
            $buttons[] = new single_button(
-
 
91
                new moodle_url(
-
 
92
                    '/badges/edit.php',
-
 
93
                    $editparams,
91
            $buttons[] = new single_button(new moodle_url('/badges/newbadge.php', $params),
94
                ),
-
 
95
                get_string('newbadge', 'core_badges'),
-
 
96
                'post',
-
 
97
                single_button::BUTTON_PRIMARY,
92
                get_string('newbadge', 'core_badges'), 'post', single_button::BUTTON_PRIMARY);
98
            );
Línea 93... Línea 99...
93
        }
99
        }
94
 
100
 
95
        foreach ($buttons as $key => $button) {
101
        foreach ($buttons as $key => $button) {