original_string: public function toggle_visibility($force = null) {
          global $DB;
  
          // Set visible to the default if it is not already set.
          if (empty($this->properties->visible)) {
              $this->properties->visible = 1;
          }
  
          if ($force === true || ($force !== false && $this->properties->visible == 0)) {
              // Make this event visible.
              $this->properties->visible = 1;
          } else {
              // Make this event hidden.
              $this->properties->visible = 0;
          }
  
          // Update the database to reflect this change.
          $success = $DB->set_field('event', 'visible', $this->properties->visible, array('id' => $this->properties->id));
          $calendarevent = $DB->get_record('event',  array('id' => $this->properties->id), '*', MUST_EXIST);
  
          // Prepare event data.
          $eventargs = array(
              'context' => $this->get_context(),
              'objectid' => $this->properties->id,
              'other' => array(
                  'repeatid' => empty($this->properties->repeatid) ? 0 : $this->properties->repeatid,
                  'timestart' => $this->properties->timestart,
                  'name' => $this->properties->name
              )
          );
          $event = \core\event\calendar_event_updated::create($eventargs);
          $event->add_record_snapshot('event', $calendarevent);
          $event->trigger();
  
          return $success;
      }
code: public function toggle_visibility($force = null) {
          global $DB;
  
          // Set visible to the default if it is not already set.
          if (empty($this->properties->visible)) {
              $this->properties->visible = 1;
          }
  
          if ($force === true || ($force !== false && $this->properties->visible == 0)) {
              // Make this event visible.
              $this->properties->visible = 1;
          } else {
              // Make this event hidden.
              $this->properties->visible = 0;
          }
  
          // Update the database to reflect this change.
          $success = $DB->set_field('event', 'visible', $this->properties->visible, array('id' => $this->properties->id));
          $calendarevent = $DB->get_record('event',  array('id' => $this->properties->id), '*', MUST_EXIST);
  
          // Prepare event data.
          $eventargs = array(
              'context' => $this->get_context(),
              'objectid' => $this->properties->id,
              'other' => array(
                  'repeatid' => empty($this->properties->repeatid) ? 0 : $this->properties->repeatid,
                  'timestart' => $this->properties->timestart,
                  'name' => $this->properties->name
              )
          );
          $event = \core\event\calendar_event_updated::create($eventargs);
          $event->add_record_snapshot('event', $calendarevent);
          $event->trigger();
  
          return $success;
      }
code_tokens: public function toggle_visibility ( $ force = null ) { global $ DB ; // Set visible to the default if it is not already set. if ( empty ( $ this -> properties -> visible ) ) { $ this -> properties -> visible = 1 ; } if ( $ force === true || ( $ force !== false && $ this -> properties -> visible == 0 ) ) { // Make this event visible. $ this -> properties -> visible = 1 ; } else { // Make this event hidden. $ this -> properties -> visible = 0 ; } // Update the database to reflect this change. $ success = $ DB -> set_field ( 'event' , 'visible' , $ this -> properties -> visible , array ( 'id' => $ this -> properties -> id ) ) ; $ calendarevent = $ DB -> get_record ( 'event' , array ( 'id' => $ this -> properties -> id ) , '*' , MUST_EXIST ) ; // Prepare event data. $ eventargs = array ( 'context' => $ this -> get_context ( ) , 'objectid' => $ this -> properties -> id , 'other' => array ( 'repeatid' => empty ( $ this -> properties -> repeatid ) ? 0 : $ this -> properties -> repeatid , 'timestart' => $ this -> properties -> timestart , 'name' => $ this -> properties -> name ) ) ; $ event = \ core \ event \ calendar_event_updated :: create ( $ eventargs ) ; $ event -> add_record_snapshot ( 'event' , $ calendarevent ) ; $ event -> trigger ( ) ; return $ success ; }
docstring: Toggles the visibility of an event
  
  @param null|bool $force If it is left null the events visibility is flipped,
  If it is false the event is made hidden, if it is true it
  is made visible.
  @return bool if event is successfully updated, toggle will be visible
docstring_tokens: Toggles the visibility of an event