Exemplo n.º 1
0
/**
 * Returns a turn edit on/off button for course in a self contained form.
 * Used to be an icon, but it's now a simple form button
 *
 * @uses $CFG
 * @uses $USER
 * @param int $courseid The course  to update by id as found in 'course' table
 * @return string
 */
function update_course_icon($courseid)
{
    global $CFG, $USER;
    if (editcourseallowed($courseid)) {
        if (!empty($USER->editing)) {
            $string = get_string('turneditingoff');
            $edit = '0';
        } else {
            $string = get_string('turneditingon');
            $edit = '1';
        }
        return '<form ' . $CFG->frametarget . ' method="get" action="' . $CFG->wwwroot . '/course/view.php">' . '<div>' . '<input type="hidden" name="id" value="' . $courseid . '" />' . '<input type="hidden" name="edit" value="' . $edit . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="submit" value="' . $string . '" />' . '</div></form>';
    }
}
Exemplo n.º 2
0
 function user_allowed_editing()
 {
     if (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM)) && defined('ADMIN_STICKYBLOCKS')) {
         return true;
     }
     return editcourseallowed($this->id);
 }
Exemplo n.º 3
0
/**
 * Determines if the currently logged in user is in editing mode.
 * Note: originally this function had $userid parameter - it was not usable anyway
 *
 * @uses $USER
 * @param int $courseid The id of the course being tested
 * @return bool
 */
function isediting($courseid)
{
    global $USER;
    if (empty($USER->editing)) {
        return false;
    } else {
        return editcourseallowed($courseid);
    }
}