original_string: public function set_definition_sharing($definition, $sharingoption, $userinputsharingkey = null) {
          if (!array_key_exists($definition, $this->configdefinitions)) {
              throw new coding_exception('Invalid definition name passed when updating sharing options.');
          }
          if (!($this->configdefinitions[$definition]['sharingoptions'] & $sharingoption)) {
              throw new coding_exception('Invalid sharing option passed when updating definition.');
          }
          $this->configdefinitions[$definition]['selectedsharingoption'] = (int)$sharingoption;
          if (!empty($userinputsharingkey)) {
              $this->configdefinitions[$definition]['userinputsharingkey'] = (string)$userinputsharingkey;
          }
          $this->config_save();
      }
code: public function set_definition_sharing($definition, $sharingoption, $userinputsharingkey = null) {
          if (!array_key_exists($definition, $this->configdefinitions)) {
              throw new coding_exception('Invalid definition name passed when updating sharing options.');
          }
          if (!($this->configdefinitions[$definition]['sharingoptions'] & $sharingoption)) {
              throw new coding_exception('Invalid sharing option passed when updating definition.');
          }
          $this->configdefinitions[$definition]['selectedsharingoption'] = (int)$sharingoption;
          if (!empty($userinputsharingkey)) {
              $this->configdefinitions[$definition]['userinputsharingkey'] = (string)$userinputsharingkey;
          }
          $this->config_save();
      }
code_tokens: public function set_definition_sharing ( $ definition , $ sharingoption , $ userinputsharingkey = null ) { if ( ! array_key_exists ( $ definition , $ this -> configdefinitions ) ) { throw new coding_exception ( 'Invalid definition name passed when updating sharing options.' ) ; } if ( ! ( $ this -> configdefinitions [ $ definition ] [ 'sharingoptions' ] & $ sharingoption ) ) { throw new coding_exception ( 'Invalid sharing option passed when updating definition.' ) ; } $ this -> configdefinitions [ $ definition ] [ 'selectedsharingoption' ] = ( int ) $ sharingoption ; if ( ! empty ( $ userinputsharingkey ) ) { $ this -> configdefinitions [ $ definition ] [ 'userinputsharingkey' ] = ( string ) $ userinputsharingkey ; } $ this -> config_save ( ) ; }
docstring: Sets the selected sharing options and key for a definition.
  
  @param string $definition The name of the definition to set for.
  @param int $sharingoption The sharing option to set.
  @param string|null $userinputsharingkey The user input key or null.
  @throws coding_exception
docstring_tokens: Sets the selected sharing options and key for a definition .