original_string: public function save($params = array()) {
          global $DB;
  
          // Sort out criteria description.
          // If it is coming from the form editor, it is an array of (text, format).
          $description = '';
          $descriptionformat = FORMAT_HTML;
          if (isset($params['description']['text'])) {
              $description = $params['description']['text'];
              $descriptionformat = $params['description']['format'];
          } else if (isset($params['description'])) {
              $description = $params['description'];
          }
  
          $fordb = new stdClass();
          $fordb->criteriatype = $this->criteriatype;
          $fordb->badgeid = $this->badgeid;
          $fordb->description = $description;
          $fordb->descriptionformat = $descriptionformat;
          if ($this->id !== 0) {
              $fordb->id = $this->id;
              $DB->update_record('badge_criteria', $fordb);
          } else {
              // New record in DB, set aggregation to ALL by default.
              $fordb->method = BADGE_CRITERIA_AGGREGATION_ALL;
              $DB->insert_record('badge_criteria', $fordb);
          }
      }
code: public function save($params = array()) {
          global $DB;
  
          // Sort out criteria description.
          // If it is coming from the form editor, it is an array of (text, format).
          $description = '';
          $descriptionformat = FORMAT_HTML;
          if (isset($params['description']['text'])) {
              $description = $params['description']['text'];
              $descriptionformat = $params['description']['format'];
          } else if (isset($params['description'])) {
              $description = $params['description'];
          }
  
          $fordb = new stdClass();
          $fordb->criteriatype = $this->criteriatype;
          $fordb->badgeid = $this->badgeid;
          $fordb->description = $description;
          $fordb->descriptionformat = $descriptionformat;
          if ($this->id !== 0) {
              $fordb->id = $this->id;
              $DB->update_record('badge_criteria', $fordb);
          } else {
              // New record in DB, set aggregation to ALL by default.
              $fordb->method = BADGE_CRITERIA_AGGREGATION_ALL;
              $DB->insert_record('badge_criteria', $fordb);
          }
      }
code_tokens: public function save ( $ params = array ( ) ) { global $ DB ; // Sort out criteria description. // If it is coming from the form editor, it is an array of (text, format). $ description = '' ; $ descriptionformat = FORMAT_HTML ; if ( isset ( $ params [ 'description' ] [ 'text' ] ) ) { $ description = $ params [ 'description' ] [ 'text' ] ; $ descriptionformat = $ params [ 'description' ] [ 'format' ] ; } else if ( isset ( $ params [ 'description' ] ) ) { $ description = $ params [ 'description' ] ; } $ fordb = new stdClass ( ) ; $ fordb -> criteriatype = $ this -> criteriatype ; $ fordb -> badgeid = $ this -> badgeid ; $ fordb -> description = $ description ; $ fordb -> descriptionformat = $ descriptionformat ; if ( $ this -> id !== 0 ) { $ fordb -> id = $ this -> id ; $ DB -> update_record ( 'badge_criteria' , $ fordb ) ; } else { // New record in DB, set aggregation to ALL by default. $ fordb -> method = BADGE_CRITERIA_AGGREGATION_ALL ; $ DB -> insert_record ( 'badge_criteria' , $ fordb ) ; } }
docstring: Saves overall badge criteria description.
  
  @param array $params Values from the form or any other array.
docstring_tokens: Saves overall badge criteria description .