original_string: public static function protect_block($blockidorname) {
          global $DB;
  
          $syscontext = context_system::instance();
  
          require_capability('moodle/site:config', $syscontext);
  
          $block = false;
          if (is_int($blockidorname)) {
              $block = $DB->get_record('block', array('id' => $blockidorname), 'id, name', MUST_EXIST);
          } else {
              $block = $DB->get_record('block', array('name' => $blockidorname), 'id, name', MUST_EXIST);
          }
          $undeletableblocktypes = self::get_undeletable_block_types();
          if (!in_array($block->name, $undeletableblocktypes)) {
              $undeletableblocktypes[] = $block->name;
              set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
              add_to_config_log('block_protect', "0", "1", $block->name);
          }
      }
code: public static function protect_block($blockidorname) {
          global $DB;
  
          $syscontext = context_system::instance();
  
          require_capability('moodle/site:config', $syscontext);
  
          $block = false;
          if (is_int($blockidorname)) {
              $block = $DB->get_record('block', array('id' => $blockidorname), 'id, name', MUST_EXIST);
          } else {
              $block = $DB->get_record('block', array('name' => $blockidorname), 'id, name', MUST_EXIST);
          }
          $undeletableblocktypes = self::get_undeletable_block_types();
          if (!in_array($block->name, $undeletableblocktypes)) {
              $undeletableblocktypes[] = $block->name;
              set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
              add_to_config_log('block_protect', "0", "1", $block->name);
          }
      }
code_tokens: public static function protect_block ( $ blockidorname ) { global $ DB ; $ syscontext = context_system :: instance ( ) ; require_capability ( 'moodle/site:config' , $ syscontext ) ; $ block = false ; if ( is_int ( $ blockidorname ) ) { $ block = $ DB -> get_record ( 'block' , array ( 'id' => $ blockidorname ) , 'id, name' , MUST_EXIST ) ; } else { $ block = $ DB -> get_record ( 'block' , array ( 'name' => $ blockidorname ) , 'id, name' , MUST_EXIST ) ; } $ undeletableblocktypes = self :: get_undeletable_block_types ( ) ; if ( ! in_array ( $ block -> name , $ undeletableblocktypes ) ) { $ undeletableblocktypes [ ] = $ block -> name ; set_config ( 'undeletableblocktypes' , implode ( ',' , $ undeletableblocktypes ) ) ; add_to_config_log ( 'block_protect' , "0" , "1" , $ block -> name ) ; } }
docstring: Make this block type undeletable and unaddable.
  
  @param mixed $blockidorname string or int
docstring_tokens: Make this block type undeletable and unaddable .