Ignore:
Timestamp:
May 2, 2016, 12:09:23 PM (3 years ago)
Author:
jrpelegrina
Message:

Updated to moodle 3.0.3

Location:
moodle/trunk/fuentes/admin/roles
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • moodle/trunk/fuentes/admin/roles/assign.php

    r136 r1331  
    134134        }
    135135    }
     136}
     137
     138if (!empty($user) && ($user->id != $USER->id)) {
     139    $PAGE->navigation->extend_for_user($user);
     140    $PAGE->navbar->includesettingsbase = true;
    136141}
    137142
  • moodle/trunk/fuentes/admin/roles/check.php

    r136 r1331  
    5353
    5454if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
     55    $PAGE->navbar->includesettingsbase = true;
    5556    $PAGE->navigation->extend_for_user($user);
    5657    $PAGE->set_context(context_course::instance($course->id));
  • moodle/trunk/fuentes/admin/roles/classes/capability_table_base.php

    r136 r1331  
    107107
    108108            // Start the row.
    109             echo '<tr class="' . implode(' ', array_unique(array_merge(array('rolecap'),
    110                     $this->get_row_classes($capability)))) . '">';
     109            $rowattributes = $this->get_row_attributes($capability);
     110            // Handle class attributes same as other.
     111            $rowclasses = array_unique(array_merge(array('rolecap'), $this->get_row_classes($capability)));
     112            if (array_key_exists('class', $rowattributes)) {
     113                $rowclasses = array_unique(array_merge($rowclasses, array($rowattributes['class'])));
     114            }
     115            $rowattributes['class']  = implode(' ', $rowclasses);
    111116
    112117            // Table cell for the capability name.
    113             echo '<th scope="row" class="name"><span class="cap-desc">' . get_capability_docs_link($capability) .
     118            $contents = '<th scope="row" class="name"><span class="cap-desc">' . get_capability_docs_link($capability) .
    114119                '<span class="cap-name">' . $capability->name . '</span></span></th>';
    115120
    116121            // Add the cells specific to this table.
    117             $this->add_row_cells($capability);
     122            $contents .= $this->add_row_cells($capability);
    118123
    119             // End the row.
    120             echo "</tr>\n";
     124            echo html_writer::tag('tr', $contents, $rowattributes);
    121125        }
    122126
     
    169173
    170174    /**
     175     * For subclasses to override. Additional attributes to be added to
     176     * each table row for the capability
     177     *
     178     * @param stdClass $capability the capability this row relates to.
     179     * @return array attribute names and their values.
     180     */
     181    protected function get_row_attributes($capability) {
     182        return array();
     183    }
     184
     185    /**
    171186     * For subclasses to override. Output the data cells for this capability. The
    172187     * capability name cell will already have been output.
     
    175190     *
    176191     * @param stdClass $capability the capability this row relates to.
     192     * @return string html of row cells
    177193     */
    178194    protected abstract function add_row_cells($capability);
  • moodle/trunk/fuentes/admin/roles/classes/capability_table_with_risks.php

    r136 r1331  
    164164
    165165    protected function add_row_cells($capability) {
    166         $this->add_permission_cells($capability);
     166        $cells = $this->add_permission_cells($capability);
    167167        // One cell for each possible risk.
    168168        foreach ($this->allrisks as $riskname => $risk) {
    169             echo '<td class="risk ' . str_replace('risk', '', $riskname) . '">';
     169            $cells .= '<td class="risk ' . str_replace('risk', '', $riskname) . '">';
    170170            if ($risk & (int)$capability->riskbitmask) {
    171                 echo $this->get_risk_icon($riskname);
     171                $cells .= $this->get_risk_icon($riskname);
    172172            }
    173             echo '</td>';
     173            $cells .= '</td>';
    174174        }
     175        return $cells;
    175176    }
    176177
  • moodle/trunk/fuentes/admin/roles/classes/check_capability_table.php

    r136 r1331  
    8080        $a->capability = $capability->name;
    8181        $a->context = $this->contextname;
    82         echo '<td>' . $result . '</td>';
     82        return '<td>' . $result . '</td>';
    8383    }
    8484}
  • moodle/trunk/fuentes/admin/roles/classes/define_role_table_advanced.php

    r136 r1331  
    414414
    415415    public function save_changes() {
    416         global $DB;
     416        global $DB, $CFG;
    417417
    418418        if (!$this->roleid) {
     
    423423            // Updating role.
    424424            $DB->update_record('role', $this->role);
     425
     426            // This will ensure the course contacts cache is purged so name changes get updated in
     427            // the UI. It would be better to do this only when we know that fields affected are
     428            // updated. But thats getting into the weeds of the coursecat cache and role edits
     429            // should not be that frequent, so here is the ugly brutal approach.
     430            require_once($CFG->libdir . '/coursecatlib.php');
     431            coursecat::role_assignment_changed($this->role->id, context_system::instance());
    425432        }
    426433
     
    473480
    474481    protected function get_description_field($id) {
    475         return print_textarea(true, 10, 50, 50, 10, 'description', $this->role->description, 0, true);
     482        return '<textarea class="form-textarea" id="'. s($id) .'" name="description" rows="10" cols="50">' .
     483            htmlspecialchars($this->role->description) .
     484            '</textarea>';
    476485    }
    477486
     
    627636    protected function add_permission_cells($capability) {
    628637        // One cell for each possible permission.
     638        $content = '';
    629639        foreach ($this->displaypermissions as $perm => $permname) {
    630640            $strperm = $this->strperms[$permname];
     
    637647                $checked = 'checked="checked" ';
    638648            }
    639             echo '<td class="' . $permname . $extraclass . '">';
    640             echo '<label><input type="radio" name="' . $capability->name .
     649            $content .= '<td class="' . $permname . $extraclass . '">';
     650            $content .= '<label><input type="radio" name="' . $capability->name .
    641651                '" value="' . $perm . '" ' . $checked . '/> ';
    642             echo '<span class="note">' . $strperm . '</span>';
    643             echo '</label></td>';
    644         }
     652            $content .= '<span class="note">' . $strperm . '</span>';
     653            $content .= '</label></td>';
     654        }
     655        return $content;
    645656    }
    646657}
  • moodle/trunk/fuentes/admin/roles/classes/define_role_table_basic.php

    r136 r1331  
    4646        $permname = $this->allpermissions[$perm];
    4747        $defaultperm = $this->allpermissions[$this->parentpermissions[$capability->name]];
    48         echo '<td class="' . $permname . '">';
     48        $content = '<td class="' . $permname . '">';
    4949        if ($perm == CAP_ALLOW || $perm == CAP_INHERIT) {
    5050            $checked = '';
     
    5252                $checked = 'checked="checked" ';
    5353            }
    54             echo '<input type="hidden" name="' . $capability->name . '" value="' . CAP_INHERIT . '" />';
    55             echo '<label><input type="checkbox" name="' . $capability->name .
     54            $content .= '<input type="hidden" name="' . $capability->name . '" value="' . CAP_INHERIT . '" />';
     55            $content .= '<label><input type="checkbox" name="' . $capability->name .
    5656                '" value="' . CAP_ALLOW . '" ' . $checked . '/> ' . $this->strallow . '</label>';
    5757        } else {
    58             echo '<input type="hidden" name="' . $capability->name . '" value="' . $perm . '" />';
    59             echo $this->strperms[$permname] . '<span class="note">' . $this->stradvmessage . '</span>';
     58            $content .= '<input type="hidden" name="' . $capability->name . '" value="' . $perm . '" />';
     59            $content .= $this->strperms[$permname] . '<span class="note">' . $this->stradvmessage . '</span>';
    6060        }
    61         echo '</td>';
     61        $content .= '</td>';
     62        return $content;
    6263    }
    6364}
  • moodle/trunk/fuentes/admin/roles/classes/existing_role_holders.php

    r136 r1331  
    4242        $params = array_merge($params, $sortparams);
    4343
    44         $sql = "SELECT ra.id AS raid," . $this->required_fields_sql('u') . ",ra.contextid,ra.component
    45                   FROM {role_assignments} ra
     44        $fields = "SELECT ra.id AS raid," . $this->required_fields_sql('u') . ",ra.contextid,ra.component ";
     45        $countfields = "SELECT COUNT(1) ";
     46        $sql = "FROM {role_assignments} ra
    4647                  JOIN {user} u ON u.id = ra.userid
    4748                  JOIN {context} ctx ON ra.contextid = ctx.id
    4849                 WHERE $wherecondition
    4950                       AND ctx.id $ctxcondition
    50                        AND ra.roleid = :roleid
    51               ORDER BY ctx.depth DESC, ra.component, $sort";
    52         $contextusers = $DB->get_records_sql($sql, $params);
     51                       AND ra.roleid = :roleid";
     52         $order = " ORDER BY ctx.depth DESC, ra.component, $sort";
     53
     54        if (!$this->is_validating()) {
     55            $existinguserscount = $DB->count_records_sql($countfields . $sql, $params);
     56            if ($existinguserscount > $this->maxusersperpage) {
     57                return $this->too_many_results($search, $existinguserscount);
     58            }
     59        }
     60
     61        $contextusers = $DB->get_records_sql($fields . $sql . $order, $params);
    5362
    5463        // No users at all.
  • moodle/trunk/fuentes/admin/roles/classes/override_permissions_table_advanced.php

    r136 r1331  
    7474
    7575        // One cell for each possible permission.
     76        $content = '';
    7677        foreach ($this->displaypermissions as $perm => $permname) {
    7778            $strperm = $this->strperms[$permname];
     
    8485                $checked = 'checked="checked" ';
    8586            }
    86             echo '<td class="' . $permname . $extraclass . '">';
    87             echo '<label><input type="radio" name="' . $capability->name .
     87            $content .= '<td class="' . $permname . $extraclass . '">';
     88            $content .= '<label><input type="radio" name="' . $capability->name .
    8889                '" value="' . $perm . '" ' . $checked . $disabled . '/> ';
    8990            if ($perm == CAP_INHERIT) {
     
    9697                $strperm .= ' (' . $inherited . ')';
    9798            }
    98             echo '<span class="note">' . $strperm . '</span>';
    99             echo '</label></td>';
     99            $content .= '<span class="note">' . $strperm . '</span>';
     100            $content .= '</label></td>';
    100101        }
     102        return $content;
    101103    }
    102104}
  • moodle/trunk/fuentes/admin/roles/classes/permissions_table.php

    r136 r1331  
    6868    protected function add_row_cells($capability) {
    6969        global $OUTPUT, $PAGE;
     70        $renderer = $PAGE->get_renderer('core');
     71        $adminurl = new moodle_url("/admin/");
    7072
    7173        $context = $this->context;
     
    7577        $overridableroles = $this->overridableroles;
    7678        $roles = $this->roles;
    77 
    7879
    7980        list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
     
    9293        foreach ($roles as $id => $name) {
    9394            if (isset($needed[$id])) {
    94                 $neededroles[$id] = $roles[$id];
     95                $templatecontext = array("rolename" => $name, "roleid" => $id, "action" => "prevent", "spanclass" => "allowed",
     96                                  "linkclass" => "preventlink", "adminurl" => $adminurl->out(), "imageurl" => "");
    9597                if (isset($overridableroles[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
    96                     $preventurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'prevent'=>1));
    97                     $neededroles[$id] .= $OUTPUT->action_icon($preventurl, new pix_icon('t/delete', get_string('prevent', 'core_role')));
     98                    $templatecontext['imageurl'] = $renderer->pix_url('t/delete');
    9899                }
     100                $neededroles[$id] = $renderer->render_from_template('core/permissionmanager_role', $templatecontext);
    99101            }
    100102        }
    101         $neededroles = implode(', ', $neededroles);
     103        $neededroles = implode(' ', $neededroles);
    102104        foreach ($roles as $id => $name) {
    103105            if (isset($forbidden[$id])  and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
    104                 $forbiddenroles[$id] = $roles[$id];
     106                $templatecontext = array("rolename" => $name, "roleid" => $id, "action" => "unprohibit",
     107                                "spanclass" => "forbidden", "linkclass" => "unprohibitlink", "adminurl" => $adminurl->out(),
     108                                "imageurl" => "");
    105109                if (isset($overridableroles[$id]) and prohibit_is_removable($id, $context, $capability->name)) {
    106                     $unprohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'roleid'=>$id, 'capability'=>$capability->name, 'unprohibit'=>1));
    107                     $forbiddenroles[$id] .= $OUTPUT->action_icon($unprohibiturl, new pix_icon('t/delete', get_string('delete')));
     110                    $templatecontext['imageurl'] = $renderer->pix_url('t/delete');
    108111                }
     112                $forbiddenroles[$id] = $renderer->render_from_template('core/permissionmanager_role', $templatecontext);
    109113            }
    110114        }
    111         $forbiddenroles = implode(', ', $forbiddenroles);
     115        $forbiddenroles = implode(' ', $forbiddenroles);
    112116
    113117        if ($allowable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
    114             $allowurl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'allow'=>1));
    115             $neededroles .= '<div class="allowmore">'.$OUTPUT->action_icon($allowurl, new pix_icon('t/add', get_string('allow', 'core_role'))).'</div>';
     118            $allowurl = new moodle_url($PAGE->url, array('contextid' => $contextid,
     119                                       'capability' => $capability->name, 'allow' => 1));
     120            $allowicon = $OUTPUT->action_icon($allowurl, new pix_icon('t/add', get_string('allow', 'core_role')), null,
     121                                            array('class' => 'allowlink', 'data-action' => 'allow'));
     122            $neededroles .= html_writer::div($allowicon, 'allowmore');
    116123        }
    117124
    118125        if ($forbitable and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
    119             $prohibiturl = new moodle_url($PAGE->url, array('contextid'=>$contextid, 'capability'=>$capability->name, 'prohibit'=>1));
    120             $forbiddenroles .= '<div class="prohibitmore">'.$OUTPUT->action_icon($prohibiturl, new pix_icon('t/add', get_string('prohibit', 'core_role'))).'</div>';
     126            $prohibiturl = new moodle_url($PAGE->url, array('contextid' => $contextid,
     127                                          'capability' => $capability->name, 'prohibit' => 1));
     128            $prohibiticon = $OUTPUT->action_icon($prohibiturl, new pix_icon('t/add', get_string('prohibit', 'core_role')), null,
     129                                                array('class' => 'prohibitlink', 'data-action' => 'prohibit'));
     130            $forbiddenroles .= html_writer::div($prohibiticon, 'prohibitmore');
    121131        }
    122132
    123133        $risks = $this->get_risks($capability);
    124134
    125         echo '<td>' . $risks . '</td>';
    126         echo '<td>' . $neededroles . '</td>';
    127         echo '<td>' . $forbiddenroles . '</td>';
     135        $contents = html_writer::tag('td', $risks, array('class' => 'risks'));
     136        $contents .= html_writer::tag('td', $neededroles, array('class' => 'allowedroles'));
     137        $contents .= html_writer::tag('td', $forbiddenroles, array('class' => 'forbiddenroles'));
     138        return $contents;
    128139    }
    129140
     
    148159        return $return;
    149160    }
     161
     162    /**
     163     * Add additional attributes to row
     164     *
     165     * @param stdClass $capability capability that this table row relates to.
     166     * @return array key value pairs of attribute names and values.
     167     */
     168    protected function get_row_attributes($capability) {
     169        return array(
     170                'data-id' => $capability->id,
     171                'data-name' => $capability->name,
     172                'data-humanname' => get_capability_string($capability->name),
     173        );
     174    }
    150175}
  • moodle/trunk/fuentes/admin/roles/classes/view_role_definition_table.php

    r136 r1331  
    130130            $default = "&#xa0;";
    131131        }
    132         echo '<td class="' . $permname . '">' . $this->strperms[$permname] . '<span class="note">' .
     132        return '<td class="' . $permname . '">' . $this->strperms[$permname] . '<span class="note">' .
    133133            $default . '</span></td>';
    134134
  • moodle/trunk/fuentes/admin/roles/define.php

    r136 r1331  
    202202        array(
    203203            'context' => $systemcontext,
    204             'objectid' => $roleid
     204            'objectid' => $tableroleid
    205205        )
    206206    );
  • moodle/trunk/fuentes/admin/roles/module.js

    r136 r1331  
    5454            this.input = Y.Node.create('<input type="text" id="'+this.table.get('id')+'capabilitysearch" value="'+Y.Escape.html(filtervalue)+'" />');
    5555            // Create a label for the search input.
    56             this.label = Y.Node.create('<label for="'+this.input.get('id')+'">'+M.str.moodle.filter+' </label>');
     56            this.label = Y.Node.create('<label for="'+this.input.get('id')+'">'+M.util.get_string('filter', 'moodle')+' </label>');
    5757            // Create a clear button to clear the input.
    58             this.button = Y.Node.create('<input type="button" value="'+M.str.moodle.clear+'" />').set('disabled', filtervalue=='');
     58            this.button = Y.Node.create('<input type="button" value="'+M.util.get_string('clear', 'moodle')+'" />').set('disabled', filtervalue=='');
    5959
    6060            // Tie it all together
  • moodle/trunk/fuentes/admin/roles/permissions.php

    r136 r1331  
    6060
    6161if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
     62    $PAGE->navbar->includesettingsbase = true;
    6263    $PAGE->navigation->extend_for_user($user);
    63     $PAGE->set_context(context_course::instance($course->id));
     64    $PAGE->set_context(context_user::instance($user->id));
    6465} else {
    6566    $PAGE->set_context($context);
     
    195196echo $OUTPUT->heading($title);
    196197
     198$adminurl = new moodle_url('/admin/');
     199$arguments = array('contextid' => $contextid,
     200                'contextname' => $contextname,
     201                'adminurl' => $adminurl->out());
     202$PAGE->requires->strings_for_js(
     203                                array('roleprohibitinfo', 'roleprohibitheader', 'roleallowinfo', 'roleallowheader',
     204                                    'confirmunassigntitle', 'confirmroleunprohibit', 'confirmroleprevent', 'confirmunassignyes',
     205                                    'confirmunassignno'), 'core_role');
     206$PAGE->requires->js_call_amd('core/permissionmanager', 'initialize', array($arguments));
    197207$table = new core_role_permissions_table($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles);
    198208echo $OUTPUT->box_start('generalbox capbox');
  • moodle/trunk/fuentes/admin/roles/usersroles.php

    r136 r1331  
    133133}
    134134echo $OUTPUT->header();
    135 echo $OUTPUT->heading($title, 3);
     135echo $OUTPUT->heading($title);
    136136echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
    137137
Note: See TracChangeset for help on using the changeset viewer.