Ejemplo n.º 1
0
/**
 * Checks if there exists a record above that has the locked flag set to true
 * @param $categoryid
 * @param $pluginname
 * @return bool true if locked, false if not locked
 *
 */
function is_block_locked($categoryid, $pluginname)
{
    return is_plugin_locked($categoryid, $pluginname, 'block');
}
Ejemplo n.º 2
0
$stractivities = get_string("activities");
$strhide = get_string("hide");
$strshow = get_string("show");
$strclearheading = get_string('clear_title', 'local_contextadmin');
$stroverrideheading = get_string('override_title', 'local_contextadmin');
$strlockedheading = get_string('locked_title', 'local_contextadmin');
$stroverridevalueheading = get_string('override_value_title', 'local_contextadmin');
$strsettings = get_string("settings");
$stractivitymodule = get_string("activitymodule");
$strshowmodulecourse = get_string('showmodulecourse');
$haseditsettingscapability = has_capability('local/contextadmin:editowncatsettings', $context);
$haseditvisibilitycapability = has_capability('local/contextadmin:changevisibilty', $context);
// If data submitted, then process and store.
if (!empty($parammodulename) and confirm_sesskey() && ($haseditvisibilitycapability or $haseditsettingscapability) && !is_plugin_locked($catid, $parammodulename, 'modules')) {
    if ($DB->record_exists("modules", array("name" => $parammodulename))) {
        if (!is_plugin_locked($catid, $parammodulename, 'modules')) {
            if ($paramvisible !== null) {
                set_context_module_settings($catid, $parammodulename, array('visible' => $paramvisible, 'search' => ''));
            }
            if ($paramoverride !== null) {
                set_context_module_settings($catid, $parammodulename, array('override' => $paramoverride, 'search' => ''));
            }
            if ($paramlocked !== null) {
                set_context_module_settings($catid, $parammodulename, array('locked' => $paramlocked, 'search' => ''));
            }
            if ($paramclear !== null) {
                remove_category_module_values($catid, $parammodulename);
            }
        } else {
            print_error('modulelocked', 'local_contextadmin');
        }
 public function test_cascade_locked_set_module_settings()
 {
     global $COURSE;
     // Setup.
     // Test Set.
     $COURSE->category = 2;
     set_context_module_settings($COURSE->category, 'assignment', array('visible' => 1));
     $COURSE->category = 3;
     set_context_module_settings($COURSE->category, 'assignment', array('visible' => 0, 'locked' => 1));
     $COURSE->category = 2;
     $this->assertFalse((bool) is_plugin_locked($COURSE->category, 'assignment', 'modules'));
     $COURSE->category = 3;
     $this->assertFalse((bool) is_plugin_locked($COURSE->category, 'assignment', 'modules'));
     $COURSE->category = 4;
     $this->assertTrue((bool) is_plugin_locked($COURSE->category, 'assignment', 'modules'));
     $COURSE->category = 5;
     $this->assertTrue((bool) is_module_locked($COURSE->category, 'assignment'));
     // Teardown.
 }